Posts

Showing posts from March, 2003

Array Sort By Key Value Php Code Example

Example 1: php sort array by key $weight = [ 'Pete' => 75 , 'Benjamin' => 89 , 'Jonathan' => 101 ] ; ksort ( $weight ) ; Example 2: php sort array by specific key usort ( $array , function ( $a , $b ) { return ( $a [ 'specific_key' ] < $b [ 'specific_key' ] ) ? - 1 : 1 ; } ) ; Example 3: php sort array of array by key $inventory = [ [ 'price' => 10.99 , 'product' => 'foo 1' ] , [ 'price' => 5.99 , 'product' => 'foo 2' ] , [ 'price' => 100 , 'product' => 'foo 3' ] , ] ; $price = array_column ( $inventory , 'price' ) ; array_multisort ( $price , SORT_DESC , $inventory ) ; Example 4: php array sort by key value To PHP sort array by key , you should use : ksort ( ) ( for ascending order ) or krsort ( ) ( for descending order ) .

Can't Reset Root Password With --skip-grant-tables On Ubuntu 16

Answer : I found that the mysql.sock is deleted when the mysql service is stoped and mysqld_safe can't create it (I couldn't find the reason), so my solution was back up the sock folder and restore before start mysqld_safe Start server $ sudo service mysql start Go to sock folder $ cd /var/run Back up the sock $ sudo cp -rp ./mysqld ./mysqld.bak Stop server $ sudo service mysql stop Restore the sock $ sudo mv ./mysqld.bak ./mysqld Start mysqld_safe $ sudo mysqld_safe --skip-grant-tables --skip-networking & Init mysql shell mysql -u root Change password FLUSH PRIVILEGES; SET PASSWORD FOR root@'localhost' = PASSWORD('my_new_password'); For Ubuntu 19 with MySQL 8.0.17-0ubuntu2, what ended up working for me was a combination of many answers: In the MySQL's configuration file ( /etc/mysql/mysql.conf.d/mysqld.cnf on my machine), under [mysqld] , add: skip-grant-tables = 1 plugin-load-add = auth_socket.so Restart the

20 Mins Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Online Gdb C++ Compiler Code Example

Example 1: c++ online compiler This two are good C ++ compilers : https : //www.onlinegdb.com/online_c++_compiler https : //www.programiz.com/cpp-programming/online-compiler/ Example 2: cpp online compiler Best Site With auto compile : https : //godbolt.org/z/nEo4j7

Can A Fake Second Display Be Enabled In Windows 10?

Answer : Just spent last two hours trying to figure this out. First go to Control Panel (not Settings app) Go to Adjust Screen Resolution. You will get a similar window as you did in Windows 7. Click Detect Go to display Drop Down and select "Display Device on VGA" Select Desired Resolution. If windows is unable to save your settings use the software from your video card to adjust the resolution. If you aren't able to output the display to the Fake screen only, Press Windows+P and the select "Second display only" I hope this helps. This is by far not the ideal solution, but for now it will do: I put a 102 Ohm resistor across pins 2 and 7 of my VGA port (also known as the headless Mac Mini trick), and Windows 10 now believes I have a second monitor attached. On a different computer I had to use pins 1 and 6 and reboot before the "monitor" would work. I had the same problem and came up with a fairly simple solution: Just connect your p

Addition Is Not Working In JavaScript

Answer : One or both of the variables is a string instead of a number. This makes the + do string concatenation. '2' + 2 === '22'; // true 2 + 2 === 4; // true The other arithmetic operators / * - will perform a toNumber conversion on the string(s). '3' * '5' === 15; // true A quick way to convert a string to a number is to use the unary + operator. +'2' + 2 === 4; // true ...or with your variables: +x + +y + has two uses. One is addition, the other however is string concatenation. If one or both of your variables is a string, then + will concatenate them. You will need to use parseInt or parseFloat to turn a string into a number. In Javascript the + operator can either perform addition or concatenation depending on the type of its operands. When numbers are used with + it uses addition, but when strings are used with + it concatenates (joins the strings) instead

Check If Not Equal To In Excel Code Example

Example 1: excel logical not equal Equal to = = A1 = B1 The formula returns TRUE if a value in cell A1 is equal to the values in cell B1; FALSE otherwise. Not equal to <> = A1 <> B1 The formula returns TRUE if a value in cell A1 is not equal to the value in cell B1; FALSE otherwise. Greater than > = A1 > B1 The formula returns TRUE if a value in cell A1 is greater than a value in cell B1; otherwise it returns FALSE. Less than < = A1 < B1 The formula returns TRUE if a value in cell A1 is less than in cell B1; FALSE otherwise. Greater than or equal to >= = A1 >= B1 The formula returns TRUE if a value in cell A1 is greater than or equal to the values in cell B1; FALSE otherwise. Less than or equal to <= = A1 <= B1 The formula returns TRUE if a value in cell A1 is less than or equal to the values in cell B1; FALSE otherwise. Example 2: if equal to excel =IF(A1="red",true result,false result)

Youtube To Mp33 Code Example

Example 1: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/ Example 2: yt to mp3 Youtube - DL works great . Download from https : //youtube-dl.org/. To use, type youtube-dl <url> --audio-format mp3 Example 3: youtube to mp3 online This man is doing gods work

Android Support Design TabLayout: Gravity Center And Mode Scrollable

Answer : Tab gravity only effects MODE_FIXED . One possible solution is to set your layout_width to wrap_content and layout_gravity to center_horizontal : <android.support.design.widget.TabLayout android:id="@+id/sliding_tabs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" app:tabMode="scrollable" /> If the tabs are smaller than the screen width, the TabLayout itself will also be smaller and it will be centered because of the gravity. If the tabs are bigger than the screen width, the TabLayout will match the screen width and scrolling will activate. this is how i did it TabLayout.xml <android.support.design.widget.TabLayout android:id="@+id/tab_layout" android:layout_height="wrap_content" android:layout_width="wrap_content" android:background=&q

Angular Fullscreen Background Image With Demo Code Example

Example 1: how to cover full image in css body { background-position: center; background-repeat: no-repeat; background-size: cover; } Example 2: bootstrap create full screen background image .wrapper{background: url('/assets/64531/green_suburb.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover;}

Bootstrap 4 Center Vertical And Horizontal Alignment

Answer : Update 2019 - Bootstrap 4.3.1 There's no need for extra CSS . What's already included in Bootstrap will work. Make sure the container(s) of the form are full height . Bootstrap 4 now has a h-100 class for 100% height... Vertical center: <div class="container h-100"> <div class="row h-100 justify-content-center align-items-center"> <form class="col-12"> <div class="form-group"> <label for="formGroupExampleInput">Example label</label> <input type="text" class="form-control" id="formGroupExampleInput" placeholder="Example input"> </div> <div class="form-group"> <label for="formGroupExampleInput2">Another label</label> <input type="text" class="form-control" id="formGroupExampleInput2" placeholder="

Array.pop Javascript Code Example

Example 1: removing first item array js var list = [ "bar" , "baz" , "foo" , "qux" ] ; list . shift ( ) //["baz", "foo", "qux"] Example 2: javascript remove last element from array array . pop ( ) ; //returns popped element //example var fruits = [ "Banana" , "Orange" , "Apple" , "Mango" ] ; fruits . pop ( ) ; // fruits= ["Banana", "Orange", "Apple"]; Example 3: javascript remove last element from array var colors = [ "red" , "blue" , "green" ] ; colors . pop ( ) ; Example 4: how to remove last element in js var array = [ 1 , 2 , 3 , 4 , 5 , 6 ] ; array . pop ( ) ; console . log ( array ) ; //Output in console section: //[1, 2, 3, 4, 5] Example 5: js array pop var array = [ 'A' , 'B' , 'C' ] ; // removes and returns last element lastElement = a

Chemistry - Choosing The Right Condenser

Image
Answer : Solution 1: @Mart 's comment impelled me to return to this question and correct my answer. I've deleted incorrect material and expanded the discussion to, hopefully, provide correct information. There is a good discussion (better than the reference previously cited) of the issue here. Reflux is the process of boiling reactants while continually cooling the vapor returning it back to the flask as a liquid. It is used to heat a mixture for extended periods and at certain temperatures...A condenser is attached to the boiling flask, and cooling water is circulated to condense escaping vapors. If you are refluxing a mixture, as you might in organic synthesis to increase the speed of the reaction by doing it at a higher temperature (i.e., the boiling point of the solvent), then any of the condensers that worked well enough to avoid the loss of solvent and avoid "flooding" would work equally well. When you're refluxing, you want the "reflux rin

Apache Airflow Or Apache Beam For Data Processing And Job Scheduling

Answer : The other answers are quite technical and hard to understand. I was in your position before so I'll explain in simple terms . Airflow can do anything . It has BashOperator and PythonOperator which means it can run any bash script or any Python script. It is a way to organize (setup complicated data pipeline DAGs), schedule, monitor, trigger re-runs of data pipelines, in a easy-to-view and use UI. Also, it is easy to setup and everything is in familiar Python code. Doing pipelines in an organized manner (i.e using Airflow) means you don't waste time debugging a mess of data processing ( cron ) scripts all over the place. Apache Beam is a wrapper for the many data processing frameworks (Spark, Flink etc.) out there. The intent is so you just learn Beam and can run on multiple backends (Beam runners). If you are familiar with Keras and TensorFlow/Theano/Torch, the relationship between Keras and its backends is similar to the relationship between Beam and its

Campfire Mc Recipe Code Example

Example: can campfires start fires minecraft no, campfires don't start fires

AngularJS - Image "onload" Event

Answer : Here's a re-usable directive in the style of angular's inbuilt event handling directives: angular.module('sbLoad', []) .directive('sbLoad', ['$parse', function ($parse) { return { restrict: 'A', link: function (scope, elem, attrs) { var fn = $parse(attrs.sbLoad); elem.on('load', function (event) { scope.$apply(function() { fn(scope, { $event: event }); }); }); } }; }]); When the img load event is fired the expression in the sb-load attribute is evaluated in the current scope along with the load event, passed in as $event. Here's how to use it: HTML <div ng-controller="MyCtrl"> <img sb-load="onImgLoad($event)"> </div> JS .controller("MyCtrl", function($scope){ // ... $scope.onImgLoad = function (event) { // ... } Note: "sb" is just the prefix I

Cdn Datatables Cdn Code Example

Example: datatable cdn //DataTables 1.10.24 https://cdn.datatables.net/1.10.24/css/jquery.dataTables.min.css https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js

Uninstall Conda Environment Code Example

Example 1: conda remove environment conda remove -- name myenv -- all Example 2: delete conda env conda env remove - n ENV_NAME Example 3: conda remove env conda env remove -- name < name > Example 4: conda activate env conda activate myenv

Android Studio: How To Generate Signed Apk Using Gradle?

Answer : There are three ways to generate your build as per the buildType . (In your case, it's release but it can be named anything you want.) Go to Gradle Task in right panel of Android Studio and search for assembleRelease or assemble(#your_defined_buildtype) under Module Tasks Go to Build Variant in Left Panel and select the build from drop down Go to project root directory in File Explore and open cmd/terminal and run: Linux: ./gradlew assembleRelease or assemble(#your_defined_buildtype) Windows: gradlew assembleRelease or assemble(#your_defined_buildtype) If you want to do a release build (only), you can use Build > Generate Signed apk . For other build types, only the above three options are available. You can find the generated APK in your module/build directory having the build type name in it. It is possible to take any existing Android Studio gradle project and build/sign it from the command line without editing any files. This makes it very n

Std::distance Vector Code Example

Example: std distance // Calculates the number of elements between first and last. # include <iterator> // std::distance # include <vector> // std::vector # include <algorithm> // Just if you use std::find vector < int > arr = { 2 , 5 , 3 , 8 , 1 } ; int size = std :: distance ( arr . begin ( ) , arr . end ( ) ) ; // 5 auto it = std :: find ( arr . begin ( ) , arr . end ( ) , 8 ) ; int position = std :: distance ( arr . begin ( ) , it ) ; // 3

Are There Any Advantages To Having An Axe With Silk Touch?

Image
Answer : Looking at the page from the Minecraft Wiki, it has a few uses, which are normally unavailable to non-silk-touch axes: Harvesting Huge Mushrooms Bookshelves Harvesting Ice Mycelium Podzol Packed Ice I bolded the huge mushrooms because it is the only item that it is truly the fastest to harvest with an axe. All the other blocks in the list are better to harvest with another tool, but I put them in because it is possible to harvest with an axe. (By the way, the axe works like a normal diamond axe, with the added ability to harvest the above items) I have found a nice way to use the silk touch axe. Melons when broken by any non - silk touch tool, or by hand, gives melon slices. However If you break melons by a silk touch tool it will drop melon block. So you can say no to the tedious melon crafting. After you have a good amount of melons you can trade them for lot of emeralds. Silk touch pickaxe is slower at breaking melons than silk touch axe So an ax

5 Subfigures Latex Code Example

Example 1: subfigure latex \usepackage{caption} \usepackage{subcaption} \begin{document} \begin{figure} \begin{subfigure}{.5\textwidth} \centering % include first image \includegraphics[width=.8\linewidth]{log_demo1.png} \caption{Put your sub-caption here} \label{fig:sub-first} \end{subfigure} \begin{subfigure}{.5\textwidth} \centering % include second image \includegraphics[width=.8\linewidth]{log_demo2.png} \caption{Put your sub-caption here} \label{fig:sub-second} \end{subfigure} \newline \begin{subfigure}{.5\textwidth} \centering % include third image \includegraphics[width=.8\linewidth]{log_demo1.png} \caption{Put your sub-caption here} \label{fig:sub-third} \end{subfigure} \begin{subfigure}{.5\textwidth} \centering % include fourth image \includegraphics[width=.8\linewidth]{log_demo2.png} \caption{Put your sub-caption here} \label{fig:sub-fourth} \end{subfigure} \caption{Put your caption here} \label{fig:fig} \end{figure} Exa

Array Unique Php Code Example

Example 1: php remove duplicates from array < ? php $fruits_list = array ( 'Orange' , 'Apple' , ' Banana' , 'Cherry' , ' Banana' ) ; $result = array_unique ( $fruits_list ) ; print_r ( $result ) ; ? > Output : Array ( [ 0 ] => Orange [ 1 ] => Apple [ 2 ] => Banana [ 3 ] => Cherry ) Example 2: array_unique < ? php $input = array ( "a" => "green" , "red" , "b" => "green" , "blue" , "red" ) ; $result = array_unique ( $input ) ; print_r ( $result ) ; ? > Array ( [ a ] => green [ 0 ] => red [ 1 ] => blue ) Example 3: check duplicate data in array php $counts = array_count_values ( $array ) ; $duplicate_title = array_filter ( $array , function ( $value ) use ( $counts ) { return $counts [ $value ] > 1 ; } ) ; Example