Posts

Showing posts from December, 2000

Copy And Paste In Vi

Answer : Move the cursor to the line from where you want to copy and paste contents at another place. Hold the key v in press mode and press upper or lower arrow key according to requirements or up to lines that will be copied. you can press key V to select whole lines. Press d to cut or y to copy. Move the cursor to the place where you want to paste. Press p to paste contents after the cursor or P to paste before the cursor. You have :set paste Put Vim in Paste mode. This is useful if you want to cut or copy some text from one window and paste it in Vim. This will avoid unexpected effects. Setting this option is useful when using Vim in a terminal, where Vim cannot distinguish between typed text and pasted text. Assuming your vi is actually vim, before pasting, do: :set paste That disables word wrapping and auto-indent and all similar things that modify typed text. After pasting, tur

How To Convert Char To Int In Cpp Code Example

Example 1: char to int c++ int x = ( int ) character - 48 ; Example 2: char* to int in cpp int x = std :: stoi ( "42" ) Example 3: converting char to integer c++ int x = '9' - 48 ; // x now equals 9 as an integer Example 4: convert char to int c++ int x = character - '0' Example 5: converting char to int in c++ # include <sstream> using namespace std ; int main ( ) { stringstream str ; str << "1" ; double x ; str >> x ; }

Connecting Postgres Database From MySQL Workbench

Answer : No. That's why it is called MySQL Workbench. The reason is that the MWB uses a lot of MySQL specific functionality. I don't think there is currently something similar for Postgres, but you could try Glom or pgadmin3. A company-independent database manager is the commercial Aqua Data Studio - maybe it's worth a try.

Array Length In Python 3 Code Example

Example 1: size array python size = len ( myList ) Example 2: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3

Adding Options To A Using JQuery?

Answer : Personally, I prefer this syntax for appending options: $('#mySelect').append($('<option>', { value: 1, text: 'My option' })); If you're adding options from a collection of items, you can do the following: $.each(items, function (i, item) { $('#mySelect').append($('<option>', { value: item.value, text : item.text })); }); This did NOT work in IE8 (yet did in FF): $("#selectList").append(new Option("option text", "value")); This DID work: var o = new Option("option text", "value"); /// jquerify the DOM object 'o' so we can use the html method $(o).html("option text"); $("#selectList").append(o); You can add option using following syntax, Also you can visit to way handle option in jQuery for more details. $('#select').append($('<option>', {value:1, text:'One'}

Convert Python Code To Java Code Example

Example 1: python to java converter try jython , Refer : https : / / www . jython . org Example 2: convert python code to java for i in range ( 2 , len ( array ) ) :

Stylish Css Author Comment Code Example

Example: comment out css /* this is some commented out css .my-field{ font-size:10px; border:1px solid red; } */

Angular 4 - Conditional CSS Classes

Answer : You can do this using the class binding: <input type="email" class="form-control" [class.error-field]="error"> yeah there's a better way using ngClass attribute like this: <input type="email" [ngClass]="{'form-control': true, 'error-field': error}" /> I believe you are looking for NgClass or NgStyle: https://angular.io/api/common/NgClass https://angular.io/api/common/NgStyle

Convert Dd/mm/yyyy To Yyyy-mm-dd In Sql Code Example

Example 1: SQL query to convert DD/MM/YYYY to YYYY-MM-DD SELECT CONVERT ( varchar ( 10 ) , CONVERT ( date , ' 13 / 12 / 2016 ' , 103 ) , 120 ) Example 2: php convert date from dd/mm/yyyy to yyyy-mm-dd $date = DateTime :: createFromFormat ( 'd / m / Y' , "24/04/2012" ) ; echo $date -> format ( 'Y - m - d' ) ; Example 3: sql convert date to string yyyy-mm-dd select CONVERT ( char ( 10 ) , GetDate ( ) , 126 ) /* 2020-12-23 */ Example 4: sql server date format yyyy-mm-dd convert ( varchar , [ column_date ] , 20 ) -- ( date or datetime ) to yyyy - MM - dd HH : mm : ss convert ( varchar , [ column_date ] , 23 ) -- ( date or datetime ) to yyyy - MM - dd -- ref https : / / www . mssqltips . com / sqlservertip / 1145 / date - and - time - conversions - using - sql - server /

Cordova - Current Working Directory Is Not A Cordova-based Project

Answer : If you are getting this error on Ionic2 This issue generally occur when we just clone / download app and try to add platform to it. its very easy to resolve, then here are the steps- just create a "www" directory in application root. "./www" can also do by this command- mkdir www now we can easily run following command - ionic platform add android or ionic platform add ios Hope it will help!!! Solution is to make sure there's a www/ directory inside the root directory. mkdir www make sure your .gitignore file doesn't include www/ directory on it. Yes, as QuickFix said, you need to be in a Cordova project before being able to use most of cordova Commands. If you are curious about what defines a Cordova project, this is what I found: Has a .cordova directory, with a config.json inside. Has a www directory, with a config.xml inside. Has a platforms directory. With that in place you can use Cordoba commands without problem. If you need examples o

Can Not Run Configure Command: "No Such File Or Directory"

Answer : If the file is called configure.ac, do $> autoconf Depends: M4, Automake If you're not sure what to do, try $> cat readme They must mean that you use "autoconf" to generate an executable "configure" file. So the order is: $> autoconf $> ./configure $> make $> make install The failsafe for generating a configure script is autoreconf -i , which not only takes care of calling autoconf itself, but also a host of other tools that may be needed. It's just problem with permissions Run chmod +x ./configure Should work

Create Gameobject Unity Code Example

Example 1: gameobject in unity c# //define "myObject" //(asign in in inspector) public GameObject myObject ; //runs when you hit the play button void Start ( ) { //change the name to "myObjectsNewName" myObject . name = "myObjectsNewName" ; } //Note for Unity and C# Example 2: unity create gameobject with component GameObject go = new GameObject ( "Test" , typeof ( MeshRenderer ) , typeof ( MeshFilter ) , typeof ( YourScript ) ) ; Example 3: unity create gameobject // Use 'new GameObject' to create a new GameObject in the current scene SpawnedObject = new GameObject ( "Created GameObject" ) ; Example 4: how to add a gameobject /// < summary > /// Creates a new Gameobject called Name_1 /// </ summary > public void AddGameObject ( ) { GameObject testObject = new GameObject ( "Name_1" ) ; } Example 5: create gameobject unity using UnityEngine ; public class InstantiationExample :

Dotnet Add New Project To Solution Code Example

Example: dotnet core sloution dotnet new sln -- name my - solution dotnet new [ type ] -- name my - project dotnet sln add my - project / my - project . csproj dotnet sln list dotnet restore dotnet build my - solution . sln

Convert Byte Array To String Android Code Example

Example: convert byte array to string byte [ ] byteArray1 = { 80 , 65 , 78 , 75 , 65 , 74 } ; String str = new String ( byteArray1 , 0 , 3 , StandardCharsets . UTF_8 ) ;

1 Bit Is Equal To Byte Code Example

Example: 1 byte is equal to how many bits 1 byte = 8 bits

Could Not Find Module `Data.Map' -- It Is A Member Of The Hidden Package

Image
Answer : These general steps were helpful for me to resolve similar issues: Use Hoogle or Stackage to find the package where the module resides Note that Hoogle and Stackage are case-sensitive . Looking up Data.Map in Hoogle yields a list similar to the one below. Stackage has a slightly different style, but the basics are the same (mostly because it also uses Hoogle for lookup). The lines in green under the result headings show the name(s) of the containing (1) package(s) (in small caps) and (2) module(s) (capitalized). Open project-name.cabal in project root and add required package under build-depends: library hs-source-dirs: src build-depends: base >= 4.7 && < 5 , containers exposed-modules: Lib Issue stack build to download and build dependencies (or stack ghci if you plan to use it in the REPL) The reason you can import Data.Char and Data.List is that they are part of the package base , which is included with GHC and is always

Table Attributes Html Code Example

Example 1: html5 table <table> <thead> <tr> <th colspan= "2" >The table header</th> </tr> </thead> <tbody> <tr> <td>The table body</td> <td>with two columns</td> </tr> </tbody> </table> Example 2: table html tages <table> <tr> <!-- This is the first row --> <th>This is the heading</th> <th>Next heading to the right</th> </tr> <tr> <!-- This is the second row --> <td>This is where the table data goes</td> <td>This is the second columns data</td> </tr> </table>

Conversion Failed When Converting The Varchar Value 'b' To Data Type Int Code Example

Example: Conversion failed when converting the varchar value to data type int. CONVERT(INT, CASE WHEN IsNumeric(CONVERT(VARCHAR(12), a.value)) = 1 THEN CONVERT(VARCHAR(12),a.value) ELSE 0 END)

Convert Blob URL To Normal URL

Answer : A URL that was created from a JavaScript Blob can not be converted to a "normal" URL. A blob: URL does not refer to data the exists on the server, it refers to data that your browser currently has in memory, for the current page. It will not be available on other pages, it will not be available in other browsers, and it will not be available from other computers. Therefore it does not make sense, in general, to convert a Blob URL to a "normal" URL. If you wanted an ordinary URL, you would have to send the data from the browser to a server and have the server make it available like an ordinary file. It is possible convert a blob: URL into a data: URL, at least in Chrome. You can use an AJAX request to "fetch" the data from the blob: URL (even though it's really just pulling it out of your browser's memory, not making an HTTP request). Here's an example: var blob = new Blob(["Hello, world!"], { type: 'text/plain

Format Specifier C Programming Code Example

Example: format specifiers in c follow this for best answer with example : -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - https : //www.freecodecamp.org/news/format-specifiers-in-c/ https : //www.tutorialspoint.com/format-specifiers-in-c

COPY In Delphi Code Example

Example 1: Delphi how copy works var Source, Target : string; begin Source := '12345678'; Target := copy(Source, 3, 4); ShowMessage('Target : '+Target); end; Example 2: copy delphi {Your Cod Here} {Target} := copy({Source}, {Start}, {Distance});

Conversor Youtube Mp3 Code Example

Example: 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/

Angular Sum Array Of Objects Property Code Example

Example 1: javascript sum array of objects arr = [ { x : 1 } , { x : 3 } ] arr . reduce ( ( accumulator , current ) => accumulator + current . x , 0 ) ; Example 2: javascript sum of number in object array run . addEventListener ( "click" , function ( ) { let sum = people . reduce ( function ( a , b ) { // function(previousValue, currentValue) return { age : a . age + b . age , //select age in object array } ; } ) ; console . log ( sum ) ; //output sum of ages } ) ;

Angular 2/TypeScript: @Input/@output Or Input/output?

Answer : Angular 2 Style Guide According to the official Angular 2 style guide, STYLE 05-12 says Do use @Input and @Output instead of the inputs and outputs properties of the @Directive and @Component decorators The benefit is that (from the guide): It is easier and more readable to identify which properties in a class are inputs or outputs. If you ever need to rename the property or event name associated with @Input or @Output , you can modify it a single place. The metadata declaration attached to the directive is shorter and thus more readable. Placing the decorator on the same line makes for shorter code and still easily identifies the property as an input or output. I've personally used this style and really appreciate it helping keep the code DRY. One of the cool thing that I know you can do with decorators but I'm not if it's possible with the other way, is aliasing the variable: export class MyComponent { @Output('select') $onSelec

Borderradius In Flutter Code Example

Example 1: flutter BorderRadius.all( borderRadius: BorderRadius.circular(10) Example 2: container border radius flutter Container( child: Text( 'This is a Container', textScaleFactor: 2, style: TextStyle(color: Colors.black), ), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border( left: BorderSide( color: Colors.green, width: 3, ), ), ), height: 50, ), Example 3: flutter border radius borderRadius: BorderRadius.all(Radius.circular(5.0))

Button Colors Bootstrap Code Example

Example 1: bootstarp btn colors <button type= "button" class= "btn btn-primary" > Blue </button> <button type= "button" class= "btn btn-secondary" > Grey </button> <button type= "button" class= "btn btn-success" > Green </button> <button type= "button" class= "btn btn-danger" > Red </button> <button type= "button" class= "btn btn-warning" > Yellow </button> <button type= "button" class= "btn btn-info" >Ligth blue </button> <button type= "button" class= "btn btn-light" > White </button> <button type= "button" class= "btn btn-dark" > Black </button> <button type= "button" class= "btn btn-link" > White with blue text</button> Example 2: bootstrap 4 button <button type= "button&quo

403 Forbidden Vs 401 Unauthorized HTTP Responses

Image
Answer : A clear explanation from Daniel Irvine: There's a problem with 401 Unauthorized , the HTTP status code for authentication errors. And that’s just it: it’s for authentication, not authorization. Receiving a 401 response is the server telling you, “you aren’t authenticated–either not authenticated at all or authenticated incorrectly–but please reauthenticate and try again.” To help you out, it will always include a WWW-Authenticate header that describes how to authenticate. This is a response generally returned by your web server, not your web application. It’s also something very temporary; the server is asking you to try again. So, for authorization I use the 403 Forbidden response. It’s permanent, it’s tied to my application logic, and it’s a more concrete response than a 401. Receiving a 403 response is the server telling you, “I’m sorry. I know who you are–I believe who you say you are–but you just don’t have permi

Discord Welcome Image Bots Code Example

Example: change bot description background top.gg /* Change bot description background */ .entity-content__description { background : #7289DA ; /* blurple */ }

Get Angle By Vector2 Unity Code Example

Example: unity vector2 angle //Find the angle for the two Vectors float m_Angle = Vector2 . Angle ( m_MyFirstVector , m_MySecondVector ) ;

What Is Virtual Memory In Operating System Code Example

Example: virtual memory in os Virtual Memory is a storage mechanism which offers user an illusion of having a very big main memory . It is done by treating a part of secondary memory as the main memory . Therefore , instead of loading one long process in the main memory , the OS loads the various parts of more than one process in the main memory .

Android Numberpicker For Floating Point Numbers

Answer : NumberPicker is not just for integers.. Even you can use Floats String etc. see this and read about it. for tutorials : http://gafurbabu.wordpress.com/2012/03/29/android-number-picker-dialog/ And I had used NumberPicker long ago like this and it might be some use posting here: NumberPicker np; String nums[]= {"Select Fraction","1/64","1/32","3/64","1/16","5/64","3/32","7/64","1/8","9/64","5/32","11/64","3/16","13/64","7/32","15/64","1/4","17/64","9/32","19/64","5/16","21/64","11/32","23/64","3/8","25/64","13/32","27/64","7/16","29/64"}; np = (NumberPicker) findViewById(R.id.np); np.setMaxValue(nums.length-1); np.setMin

Angular 4 Reactive Form Email Validation By Regular Expression Fail

Answer : The pattern is not correct as a string. In deed you are inside a string so to escape '.' you need to use double backslash like: emailRegEx = '^[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,4}$' Or if you want to avoid doing so i suggest to use: emailRegEx = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/ Edit: Keep in mind that this is a simple pattern that exclude a lot of valid email address (see RFC 5322 (sections 3.2.3 and 3.4.1) and RFC 5321). For example the angular build in email validator use the following pattern /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/