Posts

Showing posts from March, 2015

Change Nodejs Version Code Example

Example 1: how to update node js version //check node version > node - v // let's install a program called n that will let us easily switch //between Node versions. > npm install - g n //Upgrading to the latest stable version > n stable //Changing to a specific version > n 10.16 .0 Example 2: upgrade node version nvm install v12 . 16.2 Example 3: change node version Usage : nvm install < version > Download and install a < version > nvm use < version > Modify PATH to use < version > nvm ls List versions ( installed versions are blue ) Example 4: node install specific version nvm install v10 . 15 //v10.15 is a version i want. Example 5: use a specific version of node nvm use { Node version }

Bash Check If File Exists In Directory Code Example

Example 1: check if file exists bash FILE = / etc / resolv . conf if [ - f "$FILE" ] ; then echo "$FILE exists." else echo "$FILE does not exist." fi Example 2: .sh script: check if file exist #!/bin/bash if [ - e x . txt ] then echo "ok" else echo "nok" fi Example 3: .sh script: check if file exist # The most readable option when checking whether a file exist or not is # to use the test command or the old '[' or the new ' [ [ ' in combination # with the if statement. # Any of the snippets below will check whether the /etc/resolv.conf file # exists: FILE = / etc / resolv . conf if test - f "$FILE" ; then echo "$FILE exist" fi # or FILE = / etc / resolv . conf if [ - f "$FILE" ] ; then echo "$FILE exist" fi # or FILE = / etc / resolv . conf if [ [ - f "$FILE" ] ] ; then echo "$FILE exist&quo

Add Row Sql Code Example

Example 1: sql insert query --sql insert quest example INSERT INTO table_name ( column1 , column2 , column3 , ... ) VALUES ( value1 , value2 , value3 , ... ) ; Example 2: how to add records to sql table INSERT INTO Customer ( FirstName , LastName , City , Country , Phone ) VALUES ( 'Craig' , 'Smith' , 'New York' , 'USA' , 1 - 01 - 993 2800 ) Example 3: sql insert -- Note: This is specifically for SQL - Oracle -- --------------------------------------------------------------- -- OPTION 1: Insert specific values (other values will be null) -- syntax INSERT INTO < TABLE_NAME > ( < column1 > , < column2 > , < column3 > , ... ) VALUES ( < value1 > , < value2 > , < value3 > , ... ) ; -- example INSERT INTO SALES ( SALE_ID , ITEM_ID , QUANTITY , AMOUNT ) VALUES ( 631 , 13 , 4 , 59.99 ) ; -- --------------------------------------------------------------- -- OPTION 2: Insert

Angular Typescript Class Constant Code Example

Example: create constant in class typescript private static readonly myPrivateConstant : number = 5 ;

Left Rotation Of Array In Python Hackerrank Solution Code Example

Example: arrays left rotation hackerrank solution int n , d ; cin >> n ; int a [ n ] ; cin >> d ; for ( int i = 0 ; i < n ; cin >> a [ i ] , i ++ ) ; d = d % n ; for ( int i = d ; i < n ; i ++ ) cout << a [ i ] << " " ; for ( int i = 0 ; i < d ; i ++ ) cout << a [ i ] << " " ; return 0 ;

Change TextInputEditText Hint Color

Answer : The fix for me was to set the hint and the textColor on TextInputLayout, rather than on TextInputEditText as described here: https://material.io/develop/android/components/text-input-layout/ <android.support.design.widget.TextInputLayout android:id="@+id/passwordTextInputLayout" android:hint="@string/add_nitrogen_template_name_label" android:textColorHint="@color/warm_grey"> <android.support.design.widget.TextInputEditText android:textAppearance="@style/TextAppearance.Regular" android:textColor="@color/white"/> </android.support.design.widget.TextInputLayout> have you tried also these attributes for your AppTheme ? <item name="colorControlNormal">@color/primary</item> <item name="colorControlHighlight">@color/warm_grey</item> <item name="colorControlActivated">@color/warm_g

Add Apps To Startup Windows 10 Code Example

Example 1: win 10 add program to startup Adding app to startup manually: 1. Create app shortcut 2. Drag and drop in C:\Users\USERNAME\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup To test if the app is added successfully: 1. Open task manager 2. Go to Startup 3. The app will be visible Example 2: run app at startup in Windows 10 Add an app to run automatically at startup in Windows 10: 1. Find the app you want to run at startup, select the Start button and scroll to find the app, look on your desktop to find the app or use the search option. 2. Right-click the app, select More, and then select Open file location. This opens the location where the shortcut to the app is saved. If there isn't an option for Open file location, it means the app can't run at startup. 3. With the file location open, press the Windows logo key + R, type shell:startup, then select OK. This opens the Startup folder. 4. Copy and paste the shortcut to the ap

Android: Let User Pick Image Or Video From Gallery

Answer : Pick Audio file from Gallery: //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI); Pick Video file from Gallery: //Use MediaStore.Audio.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Video.Media.EXTERNAL_CONTENT_URI); Pick Image from gallery: //Use MediaStore.Images.Media.EXTERNAL_CONTENT_URI Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); Pick Media Files or images: Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType("image/* video/*"); You start the gallery as such: Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/* video/*"); startActivityForResult(pickIntent, IMAGE_PICKER_SELECT); then in your onActivityResult y

Bundler: You Must Use Bundler 2 Or Greater With This Lockfile

Answer : I had a similar experience. Here's how I solved it Display a list of all your local gems for the bundler gem gem list bundler N/B : The command above is for rbenv version manager, the one for rvm might be different This will display the versions of the bundler gem installed locally bundler (2.1.4, default: 1.17.2) if you don't have bundler version 2 installed locally, then run gem install bundler OR gem install bundler -v 2.1.4 if you have bundler version 2 already installed locally or just installed it, then you need to simply install an update for RubyGems Package Manager locally. To do this, run gem update --system And then finally run bundle update --bundler For Docker projects in Ruby on Rails If you're experiencing this issue when trying to build your application using Docker, simply do this: Delete the Gemfile.lock file Please don't create it again by running bundle install . Run your docker build or docker-compose build comm

Automation On Google Scholar Alerts

Image
Answer : I've been using Google Scholar Alerts for the paper discovery for a while now and faced a very similar issue. Here is a scholar-alert-digest script that I wrote to aggregate all unread messages in a Markdown report . Hope this helps! For the python lovers, I created a small script that parses those mails using Gmail API, combines similar papers and asks for further actions. The code can be found here.

Bootstrap Spinner Input Code Example

Example 1: bootstrap spinner <!-- Bootstrap 5 Spinners --> < div class = " spinner-border text-primary " role = " status " > < span class = " visually-hidden " > Loading... </ span > </ div > < div class = " spinner-border text-secondary " role = " status " > < span class = " visually-hidden " > Loading... </ span > </ div > < div class = " spinner-border text-success " role = " status " > < span class = " visually-hidden " > Loading... </ span > </ div > < div class = " spinner-border text-danger " role = " status " > < span class = " visually-hidden " > Loading... </ span > </ div > < div class = " spinner-border text-warning " role = " status " > < span class = " visually-hidden "

Adb Logcar Code Example

Example: logcat android Logcat is a command - line tool that dumps a log of system messages , including stack traces when the device throws an error and messages that you have written from your app with the Log class .

Can't Change Custom Class Of UIButton To GIDSignInButton

Image
Answer : You should try assign GIDSignInButton not to the Button Object from the Object library but to the the View Object instead It's work for me. It will look like this using UIView instead of UIButton. That's because GIDSignInButton is a subclass of UIView, not UIButton. Add to the storyboard / nib a regular UIView and change it's class to GIDSignInButton instead. From google doc: Add a GIDSignInButton to your storyboard, XIB file, or instantiate it programmatically. To add the button to your storyboard or XIB file, add a View and set its custom class to GIDSignInButton. You can create UIButton and then on its action method you can write this code for signing via google: GIDSignIn.sharedInstance().signIn() It works for me, in this way you can customize UIButton according to your requirement and also perform signin by using google

Base64 Encode Php Code Example

Example 1: php detect base64 encoding function is_base64_encoded ( $data ) { if ( preg_match ( '%^[a-zA-Z0-9/+]*={0,2}$%' , $data ) ) { return TRUE ; } else { return FALSE ; } } ; is_base64_encoded ( "iash21iawhdj98UH3" ) ; // true is_base64_encoded ( "#iu3498r" ) ; // false is_base64_encoded ( "asiudfh9w=8uihf" ) ; // false is_base64_encoded ( "a398UIhnj43f/1!+sadfh3w84hduihhjw==" ) ; // false Example 2: how do decode base64 php base64_decode ( 'base64-string-goes-here' ) ; Example 3: echo encode base64 $ echo 'linuxhint.com' | base64

Bootstrap 3 Range Slider Code Example

Example 1: price range slider bootstrap 4 < input type = " range " name = " range " step = " 50000 " min = " 100000 " max = " 1000000 " value = " " onchange = " rangePrimary.value=value " > < input type = " text " id = " rangePrimary " /> Example 2: 3 images slider at 1 time bootstrap\ .carousel-inner .carousel-item-right.active, .carousel-inner .carousel-item-next { transform: translateX(33.33%); } .carousel-inner .carousel-item-left.active, .carousel-inner .carousel-item-prev { transform: translateX(-33.33%) } .carousel-inner .carousel-item-right, .carousel-inner .carousel-item-left{ transform: translateX(0); } Example 3: bootstrap range slider with 2 handles No, the HTML5 range input only accepts one input. I would recommend you to use something like the jQuery UI range slider for that task. Example 4: bootstrap range slider < label for = " c

AttributeError: Module 'tensorflow' Has No Attribute 'placeholder' Code Example

Example: AttributeError: module 'tensorflow' has no attribute 'placeholder' site:stackoverflow.com import tensorflow.compat.v1 as tf tf.disable_v2_behavior()

How To Use CFrame Roblox Code Example

Example: Cframe guide -- //Normal CFrame CFrame . new ( 0 , 0 , 0 ) -- //Quaternion CFrame CFrame . new ( 5 , 5 , 5 , 0 , 0 , 0 , 0 ) W , X , Y , Z

Bootstrap Accordion Codepen Code Example

Example 1: bootstrap 4 accordion < div id = " accordion " > < div class = " card " > < div class = " card-header " id = " headingOne " > < h5 class = " mb-0 " > < button class = " btn btn-link " data-toggle = " collapse " data-target = " #collapseOne " aria-expanded = " true " aria-controls = " collapseOne " > Collapsible Group Item #1 </ button > </ h5 > </ div > < div id = " collapseOne " class = " collapse show " aria-labelledby = " headingOne " data-parent = " #accordion " > < div class = " card-body " > Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. 3 wolf moon officia aute, non cupidatat skateboard dolor brunch. Food truck quinoa n

Are There Any Drawbacks To Relying On The System.Guid.NewGuid() Function When Looking For Unique IDs For Data?

Answer : I'm looking to generate unique ids for identifying some data in my system. I'd recommend a GUID then, since they are by definition globally unique identifiers . I'm using an elaborate system which concatenates some (non unique, relevant) meta-data with System.Guid.NewGuid(). Are there any drawbacks to this approach, or am I in the clear? Well, since we do not know what you would consider a drawback, it is hard to say. A number of possible drawbacks come to mind: GUIDs are big: 128 bits is a lot of bits. GUIDs are not guaranteed to have any particular distribution; it is perfectly legal for GUIDs to be generated sequentially, and it is perfectly legal for the to be distributed uniformly over their 124 bit space (128 bits minus the four bits that are the version number of course.) This can have serious impacts on database performance if the GUID is being used as a primary key on a database that is indexed into sorted order by the GUID; insertion