Posts

Brew Install Yarn Code Example

Example 1: install yarn npm install -g yarn Example 2: macos install yarn brew install yarn Example 3: yarn for mac curl -o- -L https://yarnpkg.com/install.sh | bash Example 4: install yarn brew install yarn

Change Styles With Jquery Code Example

Example 1: jquery add style //revising Ankur's answer //Syntax: $ ( selector ) . css ( { property - name : property - value } ) ; //Example: $ ( '.bodytext' ) . css ( { 'color' : 'red' } ) ; Example 2: jquery modify style attribute $ ( '#yourElement' ) . css ( 'display' , 'none' ) ; Example 3: set css using jquery $ ( '.name' ) . css ( 'color' : 'blue' ) ;

Shortcut To Format Code In Visual Studio On Mac Code Example

Example: visual studio code formatting settings mac shift + option + f ( for macOS )

Adding Password To .ssh/config

Answer : Solution 1: No, There is no method to specify or provide on the command line the password in a non-interactive manner for ssh authentication using a openssh built-in mechanism. At least not one what I know of. You could hardcode your password into expect script but it is not a good solution either. You definitely would want to use keypairs for passwordless authentication as Michael stated, in the end private key is pretty much a big password in the file. Solution 2: To avoid the string of comments: Yes, this is insecure (not even arguably insecure). I would strongly recommend you only do it in a lab situation on an isolated network or a similiar situation that does not involve production servers or potentientially production server without a full reset/format. I wanted to set this up as I don't think my 2950 switch supports private/public keys and I hope at some point to get that knowledge, but I am not there yet. Using an alias and sshpass this can be acc...

Top View Of Binary Tree Practice Gfg Code Example

Example: gfg top view of tree /* This is not the entire code. It's just the function which implements bottom view. You need to write required code. */ // Obj class is used to store node with it's distance from parent. class Obj { public : Node * root ; int dis ; // distance from parent node. distance of root node will be 0. Obj ( Node * node , int dist ) { root = node ; dis = dist ; } } ; void topView ( Node * root ) { queue < Obj * > q ; q . push ( new Obj ( root , 0 ) ) ; map < int , int > m ; while ( ! q . empty ( ) ) { Obj * ob = q . front ( ) ; q . pop ( ) ; /* insert node of unique distance from parent node. ignore repitation of distance. */ if ( m . find ( ob -> dis ) == m . end ( ) ) m [ ob -> dis ] = ob -> root -> data ; if ( ob -> root...

Plt Ploty Code Example

Example 1: matplotlib plot import matplotlib . pyplot as plt fig = plt . figure ( 1 ) #identifies the figure plt . title ( "Y vs X" , fontsize = '16' ) #title plt . plot ( [ 1 , 2 , 3 , 4 ] , [ 6 , 2 , 8 , 4 ] ) #plot the points plt . xlabel ( "X" , fontsize = '13' ) #adds a label in the x axis plt . ylabel ( "Y" , fontsize = '13' ) #adds a label in the y axis plt . legend ( ( 'YvsX' ) , loc = 'best' ) #creates a legend to identify the plot plt . savefig ( 'Y_X.png' ) #saves the figure in the present directory plt . grid ( ) #shows a grid under the plot plt . show ( ) Example 2: pyplot.plot plot ( [ x ] , y , [ fmt ] , * , data = None , * * kwargs ) plot ( [ x ] , y , [ fmt ] , [ x2 ] , y2 , [ fmt2 ] , . . . , * * kwargs )

Sprintf Php Calculation Code Example

Example 1: php sprintf There are already some comments on using sprintf to force leading leading zeros but the examples only include integers . I needed leading zeros on floating point numbers and was surprised that it didn't work as expected . Example : < ? php sprintf ( '%02d' , 1 ) ; ? > This will result in 01. However , trying the same for a float with precision doesn't work : < ? php sprintf ( '%02.2f' , 1 ) ; ? > Yields 1.00 . This threw me a little off . To get the desired result , one needs to add the precision ( 2 ) and the length of the decimal seperator "." ( 1 ) . So the correct pattern would be < ? php sprintf ( '%05.2f' , 1 ) ; ? > Output : 01.00 Please see http : //stackoverflow.com/a/28739819/413531 for a more detailed explanation. Example 2: php sprintf < ? php $num = 5 ; $location = 'tree' ; $format = 'There are %d monkeys in the %s' ; echo sp...

AddEventListener Vs Onclick

Answer : Both are correct, but none of them are "best" per se, and there may be a reason the developer chose to use both approaches. Event Listeners (addEventListener and IE's attachEvent) Earlier versions of Internet Explorer implement javascript differently from pretty much every other browser. With versions less than 9, you use the attachEvent [doc] method, like this: element.attachEvent('onclick', function() { /* do stuff here*/ }); In most other browsers (including IE 9 and above), you use addEventListener [doc], like this: element.addEventListener('click', function() { /* do stuff here*/ }, false); Using this approach (DOM Level 2 events), you can attach a theoretically unlimited number of events to any single element. The only practical limitation is client-side memory and other performance concerns, which are different for each browser. The examples above represent using an anonymous function[doc]. You can also add an event liste...

Short Int In C++ Code Example

Example: range of long long in c++ Long Data Type Size ( in bytes ) Range long int 4 - 2 , 147 , 483 , 648 to 2 , 147 , 483 , 647 unsigned long int 4 0 to 4 , 294 , 967 , 295 long long int 8 - ( 2 ^ 63 ) to ( 2 ^ 63 ) - 1 unsigned long long int 8 0 to 18 , 446 , 744 , 073 , 709 , 551 , 615

A4 Paper Size Height And Width Code Example

Example: Paper size a4 2480 x 3508 pixels at 300 PPI 595 x 842 pixels at 72 PPI

Blacksheep Discord Bot Code Example

Example: black sheep discord Black Sheep Is the best Discord Bot To Ever Exist It's in 1000+ servers You can read more here - http://bit.ly/botsheep

Bootstrap 4 Carousel Card Slider W3schools Code Example

Example: how to add bootstrap carousel //Author:Mohammad Arman Khan //BOOTSTYRAP CAROUSEL(SLIDER_LOCALLY KNOWN) < div id = " carouselExampleIndicators " class = " carousel slide " data-ride = " carousel " > < ol class = " carousel-indicators " > < li data-target = " #carouselExampleIndicators " data-slide-to = " 0 " class = " active " > </ li > < li data-target = " #carouselExampleIndicators " data-slide-to = " 1 " > </ li > < li data-target = " #carouselExampleIndicators " data-slide-to = " 2 " > </ li > </ ol > < div class = " carousel-inner " role = " listbox " > <!-- Slide One - Set the background image for this slide in the line below --> < div class = " carousel-item active " style = " backgr...

Ahk Print Key Code Example

Example: autohotkey hotkeys #^!s:: ;This occurs when pressed Windows Button+Control+Alt+s Send Sincerely,{enter}John Smith ; This line sends keystrokes to the active (foremost) window. return

Add Column In Table In Postgresql Code Example

Example 1: postgresql add column with constraint ALTER TABLE customers ADD COLUMN contact_name VARCHAR NOT NULL; Example 2: postgresql insert column ALTER TABLE table_name ADD COLUMN new_column_name data_type constraint; Example 3: postgres how to add field created at CREATE TABLE my_table ( id serial NOT NULL, user_name text, created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP //here ) Example 4: alter table add column postgres Alter Postgres Table

Choosing The Correct Upper And Lower HSV Boundaries For Color Detection With`cv::inRange` (OpenCV)

Image
Answer : Problem 1 : Different applications use different scales for HSV. For example gimp uses H = 0-360, S = 0-100 and V = 0-100 . But OpenCV uses H: 0-179, S: 0-255, V: 0-255 . Here i got a hue value of 22 in gimp. So I took half of it, 11, and defined range for that. ie (5,50,50) - (15,255,255) . Problem 2: And also, OpenCV uses BGR format, not RGB. So change your code which converts RGB to HSV as follows: cv.CvtColor(frame, frameHSV, cv.CV_BGR2HSV) Now run it. I got an output as follows: Hope that is what you wanted. There are some false detections, but they are small, so you can choose biggest contour which is your lid. EDIT: As Karl Philip told in his comment, it would be good to add new code. But there is change of only a single line. So, I would like to add the same code implemented in new cv2 module, so users can compare the easiness and flexibility of new cv2 module. import cv2 import numpy as np img = cv2.imread('sof.jpg') ORANGE_MIN = np....

Bootstrap 4 Datepicker

Answer : You can too override default datepicker classes like the following: the default bootstrap font size is 1rem or 16px so update .datepicker class font-size: 0.875em; or/and update the cell width and height: .datepicker td, .datepicker th { width: 1.5em; height: 1.5em; } <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.1/css/bootstrap-datepicker.min.css" rel="stylesheet"/> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"></head> <body> <main class="cont...

Can I Share MySql Database Files With Windows On Dual Boot?

Answer : Yes, it works but with some quirks. MySQL uses the same fileformats across platforms so all you need is to share the data directory. One problem is that the data directory need to have mysql as owner and group in ubuntu. And Windows is case-insensitive and Linux is case-sensitive so keep all names uniform: either the whole name lowercase or uppercase but do not mix them. From start to finish; if you already have things set up this might need some tweaking to fit your setup: Install and setup MySQL on both systems. Stop the mysql server if it is running. Make a new NTFS partition. Mark the device name (let's call it sdXN for now). Move the mysql data directory from Ubuntu to the new partition. mkdir /{mountpoint}/mysql_data sudo mv /var/lib/mysql /{mountpoint/mysql_data using mv saves permissions. Make a new mysql directory sudo mkdir /var/lib/mysql Mount the NTFS partition at /var/lib/mysql . Change the devicename to what it got when you created the NT...

Check Internet Permission Android Code Example

Example 1: android internet permission //Add this to app manifest < uses-permission android: name = " android.permission.INTERNET " /> Example 2: android internet permission < uses-permission android: name = " android.permission.INTERNET " /> Example 3: Android check internet /** * @author Pratik Butani */ public class InternetConnection { /** * CHECK WHETHER INTERNET CONNECTION IS AVAILABLE OR NOT */ public static boolean checkConnection(Context context) { final ConnectivityManager connMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); if (connMgr != null) { NetworkInfo activeNetworkInfo = connMgr.getActiveNetworkInfo(); if (activeNetworkInfo != null) { // connected to the internet // connected to the mobile provider's data plan if (activeNetworkInfo.getType() == ConnectivityManager.TYPE_WIFI) { ...

Angular 1.6.0: "Possibly Unhandled Rejection" Error

Answer : Try adding this code to your config. I had a similar issue once, and this workaround did the trick. app.config(['$qProvider', function ($qProvider) { $qProvider.errorOnUnhandledRejections(false); }]); The code you show will handle a rejection that occurs before the call to .then . In such situation, the 2nd callback you pass to .then will be called, and the rejection will be handled. However , when the promise on which you call .then is successful, it calls the 1st callback. If this callback throws an exception or returns a rejected promise, this resulting rejection will not be handled , because the 2nd callback does not handle rejections in cause by the 1st. This is just how promise implementations compliant with the Promises/A+ specification work, and Angular promises are compliant. You can illustrate this with the following code: function handle(p) { p.then( () => { // This is never caught. throw new Error(...

Bootstrap Text Bold Code Example

Example 1: text-bold bootstrap < p class = " font-weight-bold " > Bold text. </ p > Example 2: font weight bootstrap class < p class = " font-weight-bold " > Bold text. </ p > < p class = " font-weight-normal " > Normal weight text. </ p > < p class = " font-weight-light " > Light weight text. </ p > < p class = " font-italic " > Italic text. </ p > Example 3: bootstrap italic < p class = " font-italic " > Italic text. </ p > Example 4: bootstrap 4 font bold font-weight-bold Example 5: bootstrap alignemnt paragraph < p class = " text-justify " > Ambitioni dedisse scripsisse iudicaretur. Cras mattis iudicium purus sit amet fermentum. Donec sed odio operae, eu vulputate felis rhoncus. Praeterea iter est quasdam res quas ex communi. At nos hinc posthac, sitientis piros Afros. Petierunt uti sibi concilium totius Galliae i...