Uncategorized
Ruby if array include?how to check a array with a value if present.
Step -1 https://stackoverflow.com/questions/1986386/how-to-check-if-a-value-exists-in-an-array-in-ruby#:~:text=This%20is%20another%20way%20to,the%20element%20in%20the%20array.&text=This%20returns%20the%20index%20of,contains%20the%20letter%20’o’.&text=index%20still%20iterates%20over%20the,the%20value%20of%20the%20element.
Ruby find inside a hash or array
@selected_rate=@rates(“rates is a array object”).select {|rates| rates[“object_id”] == @shippo_order.rate_id } new thing is every variable or object instance we make in ruby have there won object_id,that can be aaccess by @instance or variable .object_id we can get the selected rates like :-<%=@selected_rate[0][“object_id”]%> my @rates object
rails csv to json
csv file inside email;Identifier;password;Recovery code;Fname;Lname;Department;[email protected];9012;12se74;rb9012;Rachel;Booker;Sales;[email protected];2070;04ap67;lg2070;Laura;Grey;Depot;[email protected];4081;30no86;cj4081;Craig;Johnson;Depot;[email protected];9346;14ju73;mj9346;Mary;Jenkins;Engineering;[email protected];5079;09ja61;js5079;Jamie;Smith;Engineering;Manchester
rails route multiname OrderShipping
the rails route should be added like Order_Shipping.and the class should be like class OrderShippingController < BaseController
create database in postgresql
udo -u postgres psql postgres=# create database mydb; postgres=# create user myuser with encrypted password ‘mypass’; postgres=# grant all privileges on database mydb to myuser;
Can’t install pgadmin4 repository does not have file
$ sudo curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add $ sudo sh -c ‘echo “deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/focal pgadmin4 main” > /etc/apt/sources.list.d/pgadmin4.list && apt update’ $ sudo apt update $ sudo apt install pgadmin4-web $ sudo /usr/pgadmin4/bin/setup-web.sh
How to set defer or async attributes on enqueued script tags in WordPress
<?php add_action( ‘wp_enqueue_scripts’, function () { wp_register_script( ‘my-script’, get_stylesheet_directory_uri() . ‘/assets/js/my-script.js’ ); wp_enqueue_script( ‘my-script’ ); } ); add_filter( ‘script_loader_tag’, function ( $tag, $handle ) { if ( ‘my-script’ !== $handle ) { return $tag; } return str_replace( ‘ src’, ‘ defer src’, $tag ); // defer the script //return str_replace( ‘ src’, ‘ async …
How to set defer or async attributes on enqueued script tags in WordPress Read More »
Kill port In Ubuntu
sudo kill -9 `sudo lsof -t -i:9001`
rails sh: 1: /usr/sbin/sendmail: not found in docker
you will get it soon