10-minute Lua Tutorial: The Unique Points in a Nutshell

Lua is a simple language to learn, but with plenty of power. It is object-oriented, and supports functional programming, and supports multi-threaded programming. Lua was not designed to be run alone though, and you should have in mind some other program which uses Lua already when learning Lua. It was created to be embedded in other programs, to provide a scripting environment to glue and interact with the mother program (Example: Renoise, as well as many games and game engines). You have a reason for wanting to learn Lua already so let's jump in.

Control keywords

First,...

OpenShift (RedHat) PaaS and VPS options

Web developers need a server to host their websites or web apps. Shared hosting is a bad idea due to non-standard arbitrary limits, hosting companies messing with your files without asking, and lack of ssh access or any other ports. Cheap virtual private servers from DigitalOcean or Linode are good for anyone familiar enough with Linux (or FreeBSD with D.O.). But another option is the Platform-as-a-Service (PaaS).

OpenShift is a PaaS from RedHat. It is not a VPS, but also not a shared host. It is like Heroku or Google App Engine. You don't own the server and not even a virtual...

Choosing Shell script vs Python vs Node.js vs PHP for Server-side Command Line Scripting

After decades of improvements in graphical user interfaces, the Unix command line interface still remains the most powerful way to get things done for a lot of workflows. This is due to many reasons: the difficulty of quickly and precisely moving the mouse cursor compared to the ability of touch typists to select exactly what they want (even when it's via hotkey combinations), but mainly (IMO) the expressive power of composing separate Unix commands into one pipe-separated command operating on standardized files (usually text).

It's also easy to write your own Unix commands which...

Write PHP Code in English only: Unicode/UTF-8 and the BOM

First, a general introduction to the choices of human natural language within computer programming languages.

Since the beginning of time, programming languages supported the English language and only the English language, the English version of the alphabet, encoded as ascii characters [ok, not since the beginning of time but standard since consumer Internet support had solidified]. By ASCII I am referring to the lower 7-bit American character set. Even when foreign countries were using computers and began programming them, they would still use English programming languages, even...

The Conference vs. The Unconference

Unconference is a made up word which flips the structure of a conference to produce something better.

In the past week I went to 4 organized events, each a distinct style: 1) a hackathon, 2) a film festival, 3) a conference, and 4) a BarCamp. All events were related to technology, but the style of organization and level of participation varied as well as the objectives of te organizers. The hackathon was organized by my designer friend Vi (Studio BCA) and was for startups to get design makeovers from graphic designers. I mentored at this event. The film festival, the Bitfilm...

PhantomJS vs Selenium for scraping and automated testing

Now that I have a bit of experience with both PhantomJS and Selenium (for Selenium, mostly in its scripting contexts) here are some things I can share. All of this assumes we can use Selenium's WebDriver and script it to be comparable to PhantomJS because PhantomJS is a out-of-the-browser Javascript module (like Node.js) without a web UI shell like Selenium (in the case of Selenium IDE). WebDriver can be controlled from many scripting languages (and even compiled languages) like Python and even JavaScript. Assume that anything about PhantomJS also applies to CasperJS which is a wrapper for...

JavaScript variable scoping compared to C

For the most part, JavaScript looks like a C-like language in syntax. Lines end (optionally) with semicolons, conditional expressions are in parentheses (e.g. if (a == 1)), and blocks are surrounded by braces. But there are some huge differences in both syntax and behavior. JavaScript is weakly typed, and its object oriented programming is prototype-based, much different from C++/Java. And for someone who understands how memory for C variables is allocated, JavaScript has a number of surprises in its variables and variable scoping.

  1. There's no block-level scoping,
  2. ...

Adding Facebook sharing/liking buttons to Drupal 7 content

Drupal 7 Facebook Sharing Widget Module Decision Workflow:

  1. Do you just want Facebook or do you want every social media service under the sun (Twitter, Pinterest, Reddit, Google+, LinkedIn, etc.). There are a number of smaller services which are like Facebook for a niche. Some countries have their own, especially China. Other major social networks like YouTube or Instagram aren't places to share general blog content.
  2. Do you want to add a Like button or a Share button? People tend to Like things more than they Share. Likes across Facebook are aggregated/added
  3. ...

CSS is not Turing Complete

As more and more abilities are shoved into CSS (or into various preprocessors of CSS like Sass/SCSS | Less) you wonder how far CSS3 is from being its own programming language. The answer is: it's still not a programming language. And in fact it's not even a really crappy one, as it is not shown to itself be Turing complete. (Except for some variants of Internet Explorer which allow you to use expressions as CSS values, but this is not supported and highly recommended against for performance reasons.)

You may recall from theoretical computer science classes that Alan Turing (you may...

Selenium IDE vs Selenium Webdriver vs CasperJS

Or more specifically: Selenium IDE (Firefox plugin) vs Selenium Webdriver (Python and other languages) vs CasperJS (and PhantomJS or SlimerJS)

Selenium allows you, a programmer or non-programmer, to control a web browser and make it do things that you would otherwise do manually. With that ability, you can test your website over and over (and automatically from cron), similate users, or visit any number of web pages and read data (web scraping) on them and save to a file for processing.

If you go to the Selenium website you will...

How to remotely connect to MySQL database running on a Vagrant box

While it's common to run PhpMyadmin on servers to manage MySQL databases on them, doing so can open up security holes and so many folks choose not to. But running mysql client from the command line can be painful for heavy use - although a quick "drush sql-cli" to connect to a Drupal database comes in handy. So let's say you are using Vagrant to create and provision your servers, whether local or in the cloud, and you want to use GUI tools to run queries on the database. Instead of opening up access to your mysql server to all Internet hosts and thus being vulnerable to...

Ansible in a nutshell and Ansible terms defined

Ansible is a Python script that sshes to your servers (requiring no daemon listening on the servers) and configures them according to "idempotence". Idempotency basically means you describe what state you want, Ansible figures out how to get to that state, versus you specifying what is run and how it is run. Thus you can "run" Ansible plays over and over and it does the "right thing" instead of repeating your commands. Ansible is really useful for repeatedly setting up servers which need to be set up the same way, a better approach than "ad hoc" configuring them over ssh in a shell with no...

Quickly start using Vim (and MacVim)

You've decided learning vi/vim is a good idea. You've heard it can be intimidating at first. But you know often times tools with steep learning curves are worth learning. You probably already have vim installed but if you're on Mac you should get MacVim as well: https://github.com/macvim-dev/macvim

Start vim (I mean just type 'vim' or 'vim <filename>' in a terminal. 

1. Don't start typing yet. Press 'i' to go into insert mode where you can just type and text appears like any normal text editor. Just stay in this

...

Quick MySQL cache tuning tips using Mysqltuner and Mysqladmin

MySQL is the default relational database for web today as part of the ubiquitous LAMP stack. Postgres has a reputation for better data integrity (whereas MySQL has a reputation for losing data) where MySQL runs faster at the cost of data robustness. But when you're running a few "heavy" websites, especially running Drupal or other CMS sites, then you'll be depending on your database server to perform a lot of queries quickly.

1. You want to see just how busy your database server is. Use...

Migrating from VPS or Cloud servers to OpenShift PaaS

Hackability means never having to say "it can't be done".

Amazon currently dominates the cloud computing industry it created by allowing for easily scalable and granularly billed computing time. Microsoft's Azure platform and Google's Cloud Engine (not their App Engine) are welcome competition. But then there is RedHat, a server giant which has been merely lurking, and is now trying to attract people to their own platform (or platform offerings), like the PaaS they host called OpenShift Online.

OpenShift itself is free software (which is at openshift....

Ansible tips and tricks

I wonder how many people in Vietnam know DevOps. Not everyone even agrees on what the term DevOps even means. There's no Vietnamese ops or devops community and very few people talking about it. But DevOps is something any full stack web developer needs to master nowadays, and it goes beyond being able to set up and sysadmin a Linux server.  Here I'll take devops to mean the procedures for setting up the servers which will run your organizations (web) applications, mostly in the cloud.

Ansible, Puppet, Chef: server orchestration tools using Ruby, except Ansible which...

Set up free hosting for Drupal 7 on OpenShift Online

If you're reading this, it means OpenShift is working. It means Drupal is set up using a free tier "gear" on RedHat's OpenShift PaaS. It's actually not completely easy for those of you used to a real VPS for hosting, and it's not any easier for those who are used to FTP-only shared hosting either. But you won't have to bother installing an OS, or installing Apache, PHP, and MySQL. On the other hand, you won't have much control over which version of those you run unless you code your own OpenShift "cartridges" which is much more work than simply installing packages on a server. ...

TECH.SAIGONIST.COM | Tips, tricks, hacks, howtos, & research on web development, servers, and software

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /home/tomo/web/tech.saigonist.com/drupal7/php/includes/common.inc:2776) in drupal_send_headers() (line 1486 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/bootstrap.inc).
  • Error: Class 'CToolsCssCache' not found in _cache_get_object() (line 32 of /home/tomo/web/tech.saigonist.com/drupal7/php/includes/cache.inc).
The website encountered an unexpected error. Please try again later.