Posts

Showing posts from January, 2015

Get slug of the current archive page of a taxonomy in Wordpress

To get the taxonomy slug of the current archive page, for example:

You installed an event plugin which allows you to create session tracks ("session-track", a taxonomy), e.g: session-1, session-2... (terms) And in the archive page of those session tracks, to get the slug of the current one, you just need to call:

<?php
$tax_slug = get_query_var( 'event-categories' );
echo $tax_slug;
?>

If you are on session track 1 archive page, the result will be:

session-1

For more information about taxonomies and terms in WordPress, please read:

[0] http://codex.wordpress.org/Taxonomies
[1] http://code.tutsplus.com/tutorials/understanding-and-working-with-taxonomies-and-terms-in-wordpress--cms-21051

A great tool to edit SVG image's source online

Image
I just design a vector image with Inkscape and I want to do something more with the xml source. Eventhough Inkscape has a xml editor (CTRL + SHIFT + X) but It's not intuitive enough. Here we go, this online tool is pretty cool:

http://mrdoob.com/projects/htmleditor/

The editor allows me to modify SVG's XML source and see the changes instantly, visually.


Why did I quit social media?

I decided to get out of the social media world earlier this year because of several reasons:

Information overloaded.After reading this book: http://www.dangtrinh.com/2015/01/who-am-i.html.Too much noise and people talks shit all the time.(to be updating...)



Making vector out of bitmap image using Inkscape

Image
In some cases I also have to do the design part of some websites. Something like logos, banner, t-shirts etc...  The job is way easier with the free open-sourced tool names Inkscape. In this blog post I will show you the technique I used to convert a bitmap image to vector (not pixelated when scaling).

1. Import the bitmap image as embed:

>> File >> Import... >> 

2. Select the image and choose Path >> Trace Bitmap... and set the settings as following:

* Color
* Stack scans
* Scan: 2
* Remove background (to make the background transparent)

>> click Update to preview


>> click OK to apply the trace:



3. Copy the created layer (the black one) into another Inkscape document, save it and you have a vector version of the original bitmap image:



Pretty cool huh? \m/

Responsive tables with StackTableJS

Image
Sometimes the tables will break your website because it's too big, even-though you are using bootstrap. Here is the savior:



Github repository:https://github.com/johnpolacek/stacktable.js/Official website:http://johnpolacek.github.io/stacktable.js/ Basically, StackTableJS will transform your horizontal tables into vertical tables (the headers).
0. Download the js and css file from the link above (stacktable.css and stacktable.js).

1. Make sure the table is well-formed:


<table id="mytable">
<thead>
<tr>
<th>Title 1</th>
<th>Title 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>...</td>
<td>...</td>
<tr>
...
</tbody>
</table>

2. Include the stacktable css, add this inside the head tag:

<link href="/js/stacktablejs/stacktable.css" rel="stylesheet" />

3. Include the stacktable js, add this before the body end tag (</body>):

<script src="/js/stacktablejs/stackta…

Quote of the day

Image
"There are more scary things inside than outside."

~Toni Morrison, Paradise.




What is your home?

This is a great talk about "never-give-up" kinda things when pursuing your dream by Elizabeth Gilbert, author of a The New York Times Best Seller book "Eat, Pray, Love". But, to me it's about herself defining home. What is her home? What is your home?


Source: https://www.ted.com/talks/elizabeth_gilbert_success_failure_and_the_drive_to_keep_creating
Home is where your heart is, people say. And yes it is. Gilbert's home is writing. That's where her heart is:

"And you have to understand that for me, going home did not mean returning to my family's farm. For me, going home meant returning to the work of writing because writing was my home, because I loved writing more than I hated failing at writing, which is to say that I loved writing more than I loved my own ego, which is ultimately to say that I loved writing more than I loved myself. And that's how I pushed through it."

That is where you go back to whenever you feel bad or in a hard tim…

How the Economic machine works

This is a very interesting animation video by Ray Dalio explaining how the economy works.


Even though I'm a tech guy, I always feel like I need to understand the economy. You know, questions like what affecting my income, how can I say that I'm rich or poor...something like that. But, It's really hard to get started. This video is the thing I'm looking for to achieve that, to have a general picture of the economic machine.

In only 30 minutes, Dalio worked me through all the basic concepts such as transaction, income, credit, deflation... and explained when an economy is in good time or hard time and what the individuals and governments can do. It's so great that you can see the idea presented in animation format. Some of the things in this video are Dalio's patterns and it worked for him, so maybe it will work for me and you.

In the end, he suggested his Three rules of thumbwhich I can apply to have a better understanding about the super dynamic economical worl…

How to go back to the old People Switcher interface of Chrome

Image
Are you missing this People Switching icon?


With the latest update (Jan 14, 2015), Chrome forces us to use the new interface for People Switching as following:



and this is really annoying, way more complicated than the old one. People's yelling at each other asking how to reverse the update...blah blah blah...

Here you go, there is a Chrome's setting (advanced users) to turn that new interface off:


1. Go to chrome://flags/#enable-new-avatar-menu

2. In the "Enable the new avatar menuMac, Windows, Linux" setting, choose Disable.

3. Click "Relaunch"

and the world is happy now!

Hide NginX and PHP headers to harden your server

Hiding server's information may help protecting your server from malicious server scanning from hackers. Here are some way to hide nginx and php information:

1. NginX

Install nginx-extras to have more options:

$ sudo apt-get install nginx-extras

Open the /etc/nginx/nginx.conf and add those following lines (blue ones) inside the http block:

http {
...
        server_tokens off; # hide the nginx version
        more_set_headers 'Server: My MotherFucking Server'; # Change the Server header
...
}

Then start (or restart) the nginx server:

$ sudo service start nginx


2. PHP

You can hide the php version by modify the file /etc/php5/fpm/php.ini

...
expose_php = Off
...

Restart the php5-fpm process:

$ sudo service php5-fpm restart


Cool!


Ubuntu update error "404 Not Found [IP: 91.189.91.15 80]"

A couple days ago, I's trying to upgrade my Ubuntu 12.10 server and got this annoying error:

$ sudo apt-get update

...
404  Not Found [IP: 91.189.91.15 80]
...

What's up man?

It turned out that Ubuntu 12.10 reached its End-Of-Life (totally forgot) and its repositories were moved to another server. So, all I have to do is change the archive.ubuntu.com and security.ubuntu.com package repository URLs to old-releases.ubuntu.com:

$ sudo sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list

Update again and enjoy:

$ sudo apt-get update



Reference:https://smyl.es/how-to-fix-ubuntudebian-apt-get-404-not-found-package-repository-errors-saucy-raring-quantal-oneiric-natty/

Hide categories from your WordPress homepage

Using the WordPress's Loop , pre_get_posts, you can hide certain categories from your homepage. In your theme's functions.php, add these following:

function hide_category_home( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-5, -34' );
}
return $query;
}

add_filter( 'pre_get_posts', 'hide_category_home' );

5 and 34 are IDs of categories you want to hide.

Cool!

Who Am I?

Image
I've just finished reading this great philosophical book (Vietnamese version) of a German author, Richard David Precht. "Who am I? And if so, how many? A journey through your mind.". It makes me so confused.

The first confusing thing is that I don't know whether it is a philosophical book or a scientific one about how the human's brain works. Even thought Richard used some idea from philosophers through out our history to answer (?) some serious questions about one's individual self, he pointed out a lot of scientific research on the Homo sapiens's brain. That method made me feel like I'm reading a paper about anatomy, not a book of ideas as I read the title.

Also, after reading "Who am I", I'm not sure about my existence anymore. Is this all real or are we just kinda electromagnetic pulses flowing around the universe and accidentally meet each other? Is it me or someone else's thought. Is everything happened to me really happened o…