Posts

Showing posts from June, 2009

C# Unity Convert String To Int Code Example

Example: unity to integer int . Parse ( "500" ) ;

Android InstrumentationTestCase GetFilesDir() Returns Null

Answer : I think that you are right with keeping your test data separate from tested application. You can fix problem with Null by creating files directory for Instrumentation app by executing the following commands adb shell cd /data/data/<package_id_of_instrumentation_app> mkdir files You can do above only on emulator or rooted device. Then test from your question will not fail. I did it and also uploaded file named tst.txt to files dir, all below tests were successful: assertNotNull(getInstrumentation().getContext().getFilesDir()); assertNotNull(getInstrumentation().getContext().openFileInput("tst.txt")); assertNotNull(getInstrumentation().getContext().openFileOutput("out.txt", Context.MODE_PRIVATE)); But I think more convenient way to provide data to test project is to use assets of test project where you can simply save some files and open them: assertNotNull(getInstrumentation().getContext().getAssets().open("asset.txt"))

Import Cv2 ImportError: No Module Named Cv2 Code Example

Example 1: ModuleNotFoundError: No module named 'cv2' To solve this run the following # main opencv pip install opencv - python # contrib package for the extra features pip install opencv - contrib - python The official installation instructions are on the opencv website . More info can be found here : https : //www.pyimagesearch.com/opencv-tutorials-resources-guides/ Example 2: cv2 not found python - m pip install opencv - python

Open Modal Html Code Example

Example 1: modal html <button type= "button" class= "btn btn-primary" data-toggle= "modal" data-target= "#exampleModal" data-whatever= "@mdo" >Open modal for @mdo</button> <button type= "button" class= "btn btn-primary" data-toggle= "modal" data-target= "#exampleModal" data-whatever= "@fat" >Open modal for @fat</button> <button type= "button" class= "btn btn-primary" data-toggle= "modal" data-target= "#exampleModal" data-whatever= "@getbootstrap" >Open modal for @getbootstrap</button> <div class= "modal fade" id= "exampleModal" tabindex= "-1" role= "dialog" aria-labelledby= "exampleModalLabel" aria-hidden= "true" > <div class= "modal-dialog" role= "document" > <div class= "modal

Can C++ Raise An Error When Std Array Initialization Is Too Small?

Answer : You can use std::make_array or something like it to cause the types to differ std::array<int, 6> = std::make_array(4,3,2); gives this error in gcc: <source>:30:53: error: conversion from 'array<[...],3>' to non-scalar type 'array<[...],6>' requested You can create your own layer of abstraction that complains when you don't pass the exact same number of arguments for initialization. template <std::size_t N, class ...Args> auto createArray(Args&&... values) { static_assert(sizeof...(values) == N); using First = std::tuple_element_t<0, std::tuple<Args...>>; return std::array<First, N>{values...}; } To be invoked as auto ok = createArray<6>(4, 3, 2, 1, 0, -1); auto notOk = createArray<6>(4, 3, 2}; Instead of writing your own createArray method you can use the https://en.cppreference.com/w/cpp/experimental/make_array if your compiler supports it. #include &l

Transparent Border Css Code Example

Example: border color transparent border-color's transparent property *** border-color : rgba ( 111 , 111 , 111 , 0 ) ; rgba ( 111 , 111 , 111 , 0 ) this will invisible your border color. because that rgba color has property to invisible the border or font of color if i am correct. other-wise correct my mistake thanks

Accuracy Of Ruler In Google Earth Pro?

Answer : I think that might be because there is no single, clear answer. I'll try to summarize my knowledge and the two most related questions: Google Earth, Google satellite, and Bing aerial accuracy How accurate are measurements in Google Earth? Let's start by taking Google Earth and even GIS out of the equation and only consider how accurate a measurement on an image can be. If the resolution of an image is a pixel is 1m, and you are zoomed in far enough to see individual pixels (original, not resampled for display purposes), you can measure to within +/- 1m. Now let's get that into GIS, which requires both orthorectification and georeferencing. Both can introduce error. On top of which, you're looking at errors introduced by (re)projection. Now let's put that all into Google Earth, which is providing you a seamless interface to multiple original sources. All of which may vary in their original resolution and quality of the above processes, so righ

Create Empty Np Array Code Example

Example 1: numpy empty array import numpy as np n = 2 X = np.empty(shape=[0, n]) for i in range(5): for j in range(2): X = np.append(X, [[i, j]], axis=0) print X Example 2: declare empty array of complex type python numpy.empty(shape, dtype=float, order='C') Example 3: create empty numpy array >>> np.empty([2, 2]) #Output: array([[ -9.74499359e+001, 6.69583040e-309], [ 2.13182611e-314, 3.06959433e-309]])

Android Notification.PRIORITY_MAX Is Deprecated What Is The Alternative To Show Notification On Top?

Answer : PRIORITY_MAX This constant was deprecated in API level 26. use IMPORTANCE_HIGH instead. PRIORITY_MAX int PRIORITY_MAX This constant was deprecated in API level 26. use IMPORTANCE_HIGH instead. Highest priority, for your application's most important items that require the user's prompt attention or input. Constant Value: 2 (0x00000002) // create ios channel NotificationChannel iosChannel = new NotificationChannel(IOS_CHANNEL_ID, IOS_CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH); iosChannel.enableLights(true); iosChannel.enableVibration(true); iosChannel.setLightColor(Color.GRAY); iosChannel.setLockscreenVisibility(Notification.VISIBILITY_PUBLIC); getManager().createNotificationChannel(iosChannel); https://developer.android.com/reference/android/app/Notification.html#PRIORITY_MIN In android O there was introduction of Notification channels. In particular you define Channel with constru

Cs Uppercase Code Example

Example: css all caps .uppercase { text-transform : uppercase ; } #example { text-transform : none ; /* No capitalization, the text renders as it is (default) */ text-transform : capitalize ; /* Transforms the first character of each word to uppercase */ text-transform : uppercase ; /* Transforms all characters to uppercase */ text-transform : lowercase ; /* Transforms all characters to lowercase */ text-transform : initial ; /* Sets this property to its default value */ text-transform : inherit ; /* Inherits this property from its parent element */ }

C# - How To Get Program Files (x86) On Windows 64 Bit

Answer : The function below will return the x86 Program Files directory in all of these three Windows configurations: 32 bit Windows 32 bit program running on 64 bit Windows 64 bit program running on 64 bit windows   static string ProgramFilesx86() { if( 8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432")))) { return Environment.GetEnvironmentVariable("ProgramFiles(x86)"); } return Environment.GetEnvironmentVariable("ProgramFiles"); } If you're using .NET 4, there is a special folder enumeration ProgramFilesX86: Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86) Environment.GetEnvironmentVariable("PROGRAMFILES(X86)") ?? Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

Convert Pandas Dataframe To List Code Example

Example 1: python - convert a column in a dataframe into a list myvar_list = df [ "myvar" ] . tolist ( ) Example 2: how to convert a list into a dataframe in python from pandas import DataFrame People_List = [ 'Jon' , 'Mark' , 'Maria' , 'Jill' , 'Jack' ] df = DataFrame ( People_List , columns = [ 'First_Name' ] ) print ( df ) Example 3: pandas to list df . values . tolist ( ) Example 4: pandas list to df # import pandas as pd import pandas as pd # list of strings lst = [ 'Geeks' , 'For' , 'Geeks' , 'is' , 'portal' , 'for' , 'Geeks' ] # Calling DataFrame constructor on list df = pd . DataFrame ( lst ) df Example 5: convert list to dataframe L = [ 'Thanks You' , 'Its fine no problem' , 'Are you sure' ] #create new df df = pd . DataFrame ( { 'col' : L } ) print ( df ) col 0

Android Studio How To Run Gradle Sync Manually?

Image
Answer : Android studio should have this button in the toolbar marked "Sync project with Gradle Files" EDIT: I don't know when it was changed but it now looks like this: EDIT: This is what it looks like on 3.3.1 OR by going to File -> Sync Project with Gradle Files from the menubar. WARNING : --recompile-scripts command has been deprecated since gradle 's version 5.0. To check your gradle version, run gradle -v . ./gradlew --recompile-scripts it will do a sync without building anything. Alternatively, with command line in your root project ./gradlew build It will sync and build your app, and take longer than just a Gradle sync To see all available gradle task, use ./gradlew tasks In Android Studio 3.3 it is here: According to the answer https://stackoverflow.com/a/49576954/2914140 in Android Studio 3.1 it is here: This command is moved to File > Sync Project with Gradle Files .

Android Studio XML Preview Not Showing

Answer : I had the same issue it seems some problem with the alpha material library I downgraded the material library dependency in the build.gradle to implementation 'com.google.android.material:material:1.0.0' then invalidated the cache and restarted the studio from File -> Invalidate Caches / Restart... It worked.

Adding A Column To An Existing Table In A Rails Migration

Answer : If you have already run your original migration (before editing it), then you need to generate a new migration ( rails generate migration add_email_to_users email:string will do the trick). It will create a migration file containing line: add_column :users, email, string Then do a rake db:migrate and it'll run the new migration, creating the new column. If you have not yet run the original migration you can just edit it, like you're trying to do. Your migration code is almost perfect: you just need to remove the add_column line completely (that code is trying to add a column to a table, before the table has been created, and your table creation code has already been updated to include a t.string :email anyway). Use this command at rails console rails generate migration add_fieldname_to_tablename fieldname:string and rake db:migrate to run this migration Sometimes rails generate migration add_email_to_users email:string produces a migration like th

Convert OutputStream To ByteArrayOutputStream

Answer : There are multiple possible scenarios: a) You have a ByteArrayOutputStream, but it was declared as OutputStream. Then you can do a cast like this: void doSomething(OutputStream os) { // fails with ClassCastException if it is not a BOS ByteArrayOutputStream bos = (ByteArrayOutputStream)os; ... b) if you have any other type of output stream, it does not really make sense to convert it to a BOS. (You typically want to cast it, because you want to access the result array). So in this case you simple set up a new stream and use it. void doSomething(OutputStream os) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); bos.write(something); bos.close(); byte[] arr = bos.toByteArray(); // what do you want to do? os.write(arr); // or: bos.writeTo(os); ... c) If you have written something to any kind of OutputStream (which you do not know what it is, for example because you get it from a servlet), there is no way to get that information back. You

Customized Scroll Bar In Html Code Example

Example: custom scrollbar ::-webkit-scrollbar { /* 1 */ } ::-webkit-scrollbar-button { /* 2 */ } ::-webkit-scrollbar-track { /* 3 */ } ::-webkit-scrollbar-track-piece { /* 4 */ } ::-webkit-scrollbar-thumb { /* 5 */ } ::-webkit-scrollbar-corner { /* 6 */ } ::-webkit-resizer { /* 7 */ } /* Different States */ : horizontal : vertical : decrement : increment : start : end : double-button : single-button : no-button : corner-present : window-inactive /* All toghether example */ ::-webkit-scrollbar-track-piece :start { /* Select the top half (or left half) or scrollbar track individually */ } ::-webkit-scrollbar-thumb :window-inactive { /* Select the thumb when the browser window isn't in focus */ } ::-webkit-scrollbar-button :horizontal :decrement :hover { /* Select the down or left scroll button when it's being hovered by the mouse */ } /* Example */ body ::-webkit-scrollbar { width :

Selection Sort In C With User Input Code Example

Example: Selection sort in c with console input with assending order # include <stdio.h> int main ( ) { /* Here i & j for loop counters, temp for swapping, * count for total number of elements, number[] to * store the input numbers in array. You can increase * or decrease the size of number array as per requirement */ int i , j , count , temp , number [ 25 ] ; printf ( "How many numbers u are going to enter?: " ) ; scanf ( "%d" , & count ) ; printf ( "Enter %d elements: " , count ) ; // Loop to get the elements stored in array for ( i = 0 ; i < count ; i ++ ) scanf ( "%d" , & number [ i ] ) ; // Logic of selection sort algorithm for ( i = 0 ; i < count ; i ++ ) { for ( j = i + 1 ; j < count ; j ++ ) { if ( number [ i ] > number [ j ] ) { temp = number [ i ] ; number [ i ] = number [ j ] ;

Pip Clear Cache And Reinstall Code Example

Example 1: ignore cache pip # Add --no-cache-dir before install pip --no-cache-dir install scipy Example 2: pip clear download cache pip cache dir

Convert Ppk To Pem Putty Code Example

Example 1: convert ppk to pem puttygen server1.ppk -O private-openssh -o server1.pem Example 2: convert pem to ppk Convert .pem to .ppk file format Using Putty ( Windows ) To convert the .pem file .ppk follow below points 1 . First you need to download Putty from here. 2 . Then run puttygen to convert .PEM file to .PPK file. 3 . Start puttygen and select “Load” 4 . Select your .PEM file. 5 . Putty will convert the .PEM format to .PPK format. 6 . Select “Save Private Key” A passphrase is not required but can be used if additional security is required.

Types Of Bastions Minecraft Code Example

Example 1: types of bastions minecraft lol no i'm a speedrunner Example 2: types of bastion minecraft hey , are you into modding or something ?

Conda Reinstall All Dependencies Code Example

Example 1: conda install package #To install a package in currently active enviroment conda install package-name Example 2: conda install package #To install specific package version into a specific named environment conda install package-name=2.3.4 -n some-environment

Convert To String In Javascript Code Example

Example 1: javascript convert number to string var myNumber = 120 ; var myString = myNumber . toString ( ) ; //converts number to string "120" Example 2: javascript to string num . toString ( ) ; Example 3: change no to string in js var num = 15 ; var n = num . toString ( ) ; Example 4: jquery cast to string value . toString ( ) String ( value ) value + "" Example 5: string to int javascript var text = '3.14someRandomStuff' ; var pointNum = parseFloat ( text ) ; // returns 3.14 Example 6: how to convert to string javascript function myFunction ( ) { var x1 = Boolean ( 0 ) ; var x2 = Boolean ( 1 ) ; var x3 = new Date ( ) ; var x4 = "12345" ; var x5 = 12345 ; console . log ( String ( x1 ) ) console . log ( String ( x2 ) ) console . log ( String ( x3 ) ) console . log ( String ( x4 ) ) console . log ( String ( x5 ) ) } //outputs the following: false true Wed Dec 30 2020 20 : 35 : 17 GMT - 0500 (

Can I Override !important?

Image
Answer : Ans is YES !important can be overridden but you can not override !important by a normal declaration. It has to be higher specificity than all other declarations. However it can be overridden with a higher specificity !important declaration. This code snippet in Firefox's parser will explain how it works: if (HasImportantBit(aPropID)) { // When parsing a declaration block, an !important declaration // is not overwritten by an ordinary declaration of the same // property later in the block. However, CSSOM manipulations // come through here too, and in that case we do want to // overwrite the property. if (!aOverrideImportant) { aFromBlock.ClearLonghandProperty(aPropID); return PR_FALSE; } changed = PR_TRUE; ClearImportantBit(aPropID); } Good read Specifics on CSS Specificity CSS Specificity: Things You Should Know Here's an example to show how to override CSS HTML <div id="hola" class="hola"&

Std Fill Code Example

Example: c++ vector fill # include <algorithm> # include <vector> std :: fill ( v . begin ( ) , v . end ( ) , value ) ;