Cut exact time range from mp3 on Debian/Ubuntu

Install ffmpeg program if you dont have

sudo apt-get --purge remove ffmpeg
sudo apt-get --purge autoremove

sudo apt-get install ppa-purge
sudo ppa-purge ppa:jon-severinsson/ffmpeg

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update

sudo apt-get install ffmpeg

Cut exact time range from mp3

ffmpeg -i Full.mp3 -vn -acodec copy -ss 00:08:30 -t 00:01:25 -f mp3 -threads 0 output.mp3

 

That’s all!

Form validation example using CodeIgniter

Example is about simply user creation.

Controller file(user.php)

<?php

/**
 * User controller class
 */
class User extends CI_Controller
{

	public function create()
	{
		$data=['title'=>'Create New User'];
		$this->load->library('form_validation');

		// validation rules
		$rules=array(
			array(
				'field'=>'username',
				'label'=>'Username',
				'rules'=>'required|min_length[6]',
			),
			array(
				'field'=>'password',
				'label'=>'Password',
				// user-defined validation rule via method
				'rules'=>'required|callback_checkPasswordStrength',
			),
			array(
				'field'=>'passwordConfirm',
				'label'=>'Password Confirm',
				'rules'=>'required|matches[password]',
			),
		);
		$this->form_validation->set_rules($rules);

		// failed
		if ($this->form_validation->run() === FALSE)
		{
			$this->load->view('user/create',$data);
		}
		// successfull
		else
		{
			$attrs=$this->input->post(null,true);
			$this->load->view('user/success');
		}
	}

	// user-defined validation rule via method
	public function checkPasswordStrength($password)
	{
		if (strlen($password)<5) {
			$this->form_validation->set_message('checkPasswordStrength','Password length cant be less than 5 characters');
			return false;
		}
		else if (!preg_match('/[[:punct:]]/',$password)) {
			$this->form_validation->set_message('checkPasswordStrength','Password must contain at least 1 special character');
			return false;
		}
		return true;
	}
}

View file(create.php)

<ul>
	<?php echo validation_errors('<li class="error">','</li>'); ?>
</ul>

<form action="/index.php/user/create" method="post">
	<label>Username:</label>
	<input type="text" name="username" value="<?php echo set_value('username'); ?>" />
	<?php echo form_error('username','<div class="error">','</div>'); ?>
	<br />

	<label for="">Password:</label>
	<input type="password" name="password" value="<?php echo set_value('password'); ?>" />
	<?php echo form_error('password','<div class="error">','</div>'); ?>
	<br />

	<label for="">Password Confirm:</label>
	<input type="password" name="passwordConfirm" value="<?php echo set_value('passwordConfirm'); ?>" />
	<?php echo form_error('passwordConfirm','<div class="error">','</div>'); ?>
	<br />

	<input type="submit" name="submit" value="Create" />
</form>