React dealing with radios button

By default when you create radio multiple radios with same names, check either one will uncheck the rest.

  
  
  

Try out above codes.

In jQuery we can get the value of the radio easily using:

  $('input[name="radio1"]').val();

In react we have use state to get the value of current selected radio:

  class Test extends React.Component {
      handleRadioSelection(e){
      console.log(e.target.value);
  }
  
	render(){
		return (
      	
1
2
3
4
) } } React.render(, document.getElementById('container'));

Continue reading “React dealing with radios button”

Gulp error tracking

If you are using Gulp for you workflow, there might be chance when you have some error, gulp will stop, and you rerun gulp again, wow thats really kills your productivity, especially sometime you don’t see the reflection on your browser and you seems can’t figure out whats wrong until you go check your terminal.

there is a gulp plugin called gulp-plumber helps when you do not want to break your gulp and print the error on console.

its really easy, just install and include in your gulp pipe like this.
First, install gulp-plumber as a development dependency:

npm install --save-dev gulp-plumber

Then, add it to you gulpfile.js:

var plumber = require('gulp-plumber');
var coffee = require('gulp-coffee');

gulp.src('./src/*.ext').pipe(plumber())
.pipe(coffee())
.pipe(gulp.dest('./dist'));

Gulp spawn EMFILE error

for those who faced problem with gulp when watching a big number of files.

error might looks like this:

child_process.js:935

throw errnoException(process._errno, 'spawn');
^
Error: spawn EMFILE
at errnoException (child_process.js:988:11)
at ChildProcess.spawn (child_process.js:935:11)

here is a solution for you, the reason that caused this problem is by default mac is using 256 as default number of opening files, so set the limit to a large number will fix this problem

on your terminal

ulimit -S -n 2048 # or whatever number you choose

anyway if you are not familiar with Gulp, check out this page:

Access your raspberry pi with your macbook pro

For those who have a macbook pro and raspberry pi and you do not want to use a new keyboard and monitor or mouse, you can use your macbook pro to access your raspberry pi even with screen share.

first you need to connect your raspberry pi with ethernet and USB power adaptor. which like my photo bellow the yellow as the ethernet and black as the power adaptor.

once you are connected it will automatic startup your raspberry pi, and now you can access it by ssh, well before that make sure you share your ethernet connection.

Mysql command in terminal with mamp

For those who are having problem with mysql command in terminal,

if you are getting an error message when you type mysql in command after you installed MAMP on mac,

Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

The solution is easy,

go to your terminal,

sudo nano /etc/my.cnf

and paste in this line..

[client]
socket=/Applications/MAMP/tmp/mysql/mysql.sock

click command O to save the file and command X to exit, restart your MAMP and there you go!

Clear Cache on chrome

Tips of the day, when you are doing development for some website and sometime you found that Chome cached your image or some scripts and made you always need to clear cache in order to reflect your changes.

A quick way yo clear cache is pressing and hold “Shift” and click refresh on your browser.

sometime the cache is too strong and the quick clearing cache method will not work, so the best way to do this is to stop cache of the site that you are working on.

Continue reading “Clear Cache on chrome”