Skip to main content

Posts

how to setup rails with docker on ubuntu ?

I am assuming that you already know about rails and also have setup docker on your system Create sample app and change directory rails new sample-app cd sample-app Create Dockerfile FROM ruby : 2.5 RUN apt-get update -qq && apt-get install -y nodejs postgresql-client WORKDIR /sampe-app COPY Gemfile /sampe-app/Gemfile COPY Gemfile.lock /sample-app/Gemfile.lock RUN bundle install COPY . /sampe-app COPY entrypoint.sh /usr/bin/ RUN chmod +x /usr/bin/entrypoint.sh ENTRYPOINT [ "entrypoint.sh" ] EXPOSE 3000 CMD [ "rails" , "server" , "-b" , "0.0.0.0" ] Create entrypoint.sh #!/bin/bash set -e # remove potentiallly pre existing server.pid for rails rm -f /sample-app/tmp/pids/server.pid # execute the docker containers main process exec " $@ " Create docker-compose.yml version : "3.9" services : db : image : postgres volumes : - ./tmp/db:/var/lib/postgresql/data envir...
Recent posts

How to add custom ads.txt in blogger site

How to add custom ads.txt in blogger sites? Its super easy, you just need to copy ads.txt content downloaded from adsense Select your blog from dropdown Go to settings Go to monetizatons section Enable checkbox Click on custom ads.txt Add copied content from downloaded ads.txt file and past in this box and press save

How to handle laravel fields error according to data tables editor plugin create & edit

How to handle laravel fields error according to data tables editor plugin create edit Before going to explain lets assume we want to create category and for time being we have one field that is name. And already we have controller,model and route established. For laravel field errors to be compatible with datatables editor we need to do following. Create form request for validation of category creation as below: File location: app / Http / Requests / File name: AddCategoryFormRequest.php File contents: namespace App\Http\Requests; use App\Http\Requests\CustomFormRequest; class AddCategoryFormRequest extends CustomFormRequest { public function rules() { return [ 'name' => 'required|max:255', ]; } } And category datatables and editor configuration as below: var create = new $.fn.dataTable.Editor({ ajax: {url: 'url here',type:'POST'}, table: '#categories-table...

Find UUID

How to find UUID of iPhone using on ubuntu?? This is very easy and can be done by using following command on terminal lsusb-s :`lsusb | grep iPhone | cut -d ' ' -f 4 | sed 's/://'` -v | grep iSerial | awk '{print $3}' This will give you forty 40 charactors long string

How to create virtual host on ubuntu apache2

How to create virtual host on ubuntu? create conf file under /etc/apache2/sites-available/ name it as vhosts.conf and put following contents <VirtualHost 127.0.0.3:80> ServerAdmin webmaster@test.dev ServerName test.dev ServerAlias www.test.dev DocumentRoot /var/www/html/projects/test ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> run following command to enable site sudo a2ensite vhosts.conf run following command to restart apache service sudo service apache2 restart run following command to enable rewrite mode sudo a2enmod rewrite and thats it

GIT Commands

Here some general GIT Commands How to get/show remote URL of cloned repository git remote show origin How to add all changes to git git add -A How to commit changes with message git commit -m "message here" How to push changes to master branch git push origin master How to find difference in file git diff app/helpers.php How to git export git archive master --format=zip --output=/home/jaffarhussain/citytwig_dev.zip How to delete files from git git rm -f *.DS_Store How to show log history git log -p -2

Get Specific Zone Time

Get Specific Zone DateTime from server time function getdateTimeByZone($serverZone , $userZone = 'UTC', $serverDateTime){     //$serverDateTime must be with time     $serverDateTime = date('Y-m-d H:i:s',strtotime($serverDateTime));     $schedule_date = new DateTime($serverDateTime, new DateTimeZone($serverZone));     $schedule_date-&gt;setTimeZone(new DateTimeZone($userZone));     $convertedTime =  $schedule_date-&gt;format('Y-m-d H:i:s');     return $convertedTime; } echo getdateTimeByZone('America/Los_Angeles' , 'Asia/Karachi', '2015/08/20 04:27 AM');