Posts

Showing posts from November, 2018

If we are getting problem with FFMPEG || ffmpeg thumbnailer error in rails

If we are getting problem with FFMPEG  || ffmpeg thumbnailer error in rails Safely Remove FFMPEG First 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 dist-upgrade sudo apt-get install ffmpeg And try if you still have problem then, apt-get update apt-get install build-essential git curl gawk useradd -m guest su guest cd export LOCAL_BREW_ENV="$HOME/my_graphviz" mkdir -p "$LOCAL_BREW_ENV" git clone https://github.com/Linuxbrew/brew.git "$LOCAL_BREW_ENV" export PATH="$LOCAL_BREW_ENV/bin:$LOCAL_BREW_ENV/sbin:$PATH" export MANPATH="$LOCAL_BREW_ENV/share/man:$MANPATH" export INFOPATH="$LOCAL_BREW_ENV/share/info:$INFOPATH" export HOMEBREW_CACHE="$LOCAL_BREW_ENV/var/cache" export HOMEBREW_LOGS="$LOCAL_BREW_ENV/va

flash message in javascript

In html file - <button class="click-here">Click here to show message</button> <div id="status-area"></div> In javascript file -  (function($) {     $.fn.flash_message = function(options) {              options = $.extend({         text: 'Done',         time: 1000,         how: 'before',         class_name: ''       }, options);              return $(this).each(function() {         if( $(this).parent().find('.flash_message').get(0) )           return;                  var message = $('<span />', {           'class': 'flash_message ' + options.class_name,           text: options.text         }).hide().fadeIn('fast');                  $(this)[options.how](message);                  message.delay(options.time).fadeOut('normal', function() {           $(this).remove();         });                });     }; })(jQuery); Add some css-

how to delete associated record in laravel

There are two ways to delete associated record or related record. First way is  Suppose we have two models Category and Product. we have association like category has many products. our Category model like this class Category extends Model {     /**      * Get the comments for the blog post.      */     public function products()     {         return $this->hasMany('App\Product', 'category_id');     } } our Product model like this class Product extends Model {     /**      * Get the comments for the blog post.      */     public function category()     {         return $this->belongsTo('App\Category');     } } so write this in your category model. public static function boot() {         parent::boot();         static::deleting(function($category) { // before delete() method call this              $category->products()->delete();              // do the rest of the cleanup.

how to run rake task from console

how to run rake task from console In your file_name.rake namespace rake_task   namespace first_rake     task task_first do       // some code     end     task task_second do        // some code     end   end end Now run this task rake rake_task:first_rake:task_first

Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

use Illuminate\Support\Facades\Schema;  public function boot()   {      Schema::defaultStringLength(191);    }

laravel: command not found

export PATH="$HOME/.composer/vendor/bin:$PATH" source ~/.bash_profile

send data to view from controller in laravel

There are many ways to send data to views from controller i am assuming $data you have to send in view return view('layout',['data' => $data]); return view('layout',compact('data'));  return view('layout')->with(compact('data'));  return view('layout')->withData($data);  return view('layout')->with('data',$data);

Base table or view not found: 1146 Table 'links.blogs' doesn't exist

make sure you are using create instead of table. use Schema::create to create new. Schema::create('links', function (Blueprint $table) {       $table->increments('id');       $table->timestamps(); }); some this like this

create table through migration in laravel

php artisan make:migration create_YOUR_TABLE_NAME_table --create=YOUR_TABLE_NAME For example i am creating links table php artisan make:migration create_links_table --create=links this command will generate migration like this Schema::create('links', function (Blueprint $table) {       $table->increments('id');       $table->timestamps(); });

Laravel Error 500 Whoops, looks like something went wrong – Exception

php artisan key:generate generate key php artisan config:clear clear project cache php artisan config:cache php artisan serve start server again

What is Sequence | SQL Tutorial 18

What is Sequence A Sequence is Database Object and its completely independent object. Use - Sequence are used to generate sequential integers values. and we can also create primary key values by using sequences. Example-   Suppose you are submitting bank application form with fields name, surname, dob, gender and so on.. when you click on submit records is stored in a table. but there is one more column in a table that is serial number of customer that is automatically maintained. Syntax- create sequence sequence_name; // its will start with 1 and incremented by 1 by default. 1,2,3 Now suppose we have to generate value from 100 and incremented by 10.\ create sequence emp_no Start With 100 Incremented By 10; if You want to know current value of the sequence- CURRVAL if You want to know next value of the sequence-  NEXTVAL Practice-  Step-1 - create a table create table employee( emp_id number, name varchar2(100), dob date, salary number); Step-2- creat

What is Synonyms | SQL Tutorial 19

What is Synonyms Synonyms is a permanent alias name for table Types of synonyms- public synonyms - is used by all authenticate users. private synonyms - is only used by owner of the object. By Default a synonyms to be created as private synonyms. Syntax-  create synonyms synonyms_name For table_name; create synonyms eit For employee_info_table; // now you can use synonyms instead of table name like... select * from eit; Practice-  Step-1 - create a table create table employee( emp_id number, name varchar2(100), dob date, salary number); Step-2- create a synonyms create synonyms emp for employee // by default you can not create synonym you have to connect to DBA. Step-3- conn system // enter your password step-4- grant create synonyms to rahul (use your oracle name here) step-5 conn rahul/7533 Step-6- create synonyms again create synonyms emp for employee  Now apply some operation  select * from emp;

Uploading Images With Carrierwave to S3 on Rails

Uploading Images With Carrierwave to S3 on Rails In your gem file gem 'carrierwave', '0.10.0' gem "mini_magick" gem "fog" Run bundle install In app/models/Your_model_name.rb   mount_uploader :your_field_name, ImageUploader app/uploaders/image_uploader.rb class ImageUploader < CarrierWave::Uploader::Base     include CarrierWave::MiniMagick     storage :fog     def store_dir     "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"   end     version :large do     process resize_to_limit: [800, 800]   end     version :medium, :from_version => :large do     process resize_to_limit: [500, 500]   end     version :thumb, :from_version => :medium do     process resize_to_fit: [100, 100]   end     version :square do     process :resize_to_fill => [500, 500]   end   end Create a file in ditectory config/initializers/s3.rb CarrierWave.co

An error occurred while installing rmagick (2.16.0), and Bundler cannot continue

An error occurred while installing rmagick (2.16.0), and Bundler cannot continue You have to install library of rmagick in your system. sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev

NoMethodError: undefined method `has_many?'

NoMethodError: undefined method `has_many?' In your gem file-  group :test do     gem 'capybara', '~> 2.1.0'     gem 'shoulda-matchers', '~> 3.0' end Run - bundle install in your spec_helper-  Shoulda::Matchers.configure do |config|   config.integrate do |with|     with.test_framework :rspec     with.library :rails   end end In to do TodoItem model require 'spec_helper' describe TodoItem do   it { should belong_to(:todo_list) } end In to do TodoList Model require 'spec_helper' describe TodoList do   it { should have_many(:todo_items) } end