Posts

Showing posts from December, 2006

Javascript Tonumber Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 3: string to number javascript // Method - 1 ### parseInt() ### var text = "42px" ; var integer = parseInt ( text , 10 ) ; // returns 42 // Method - 2 ### parseFloat() ### var text = "3.14someRandomStuff" ; var pointNum = parseFloat ( text ) ; // returns 3.14 // Method - 3 ### Number() ### Number ( "123" ) ; // returns 123 Number ( "12.3" ) ; // returns 12.3 Number ( "3.14someRandomStuff" ) ; // returns NaN Number ( "42px" ) ; // returns NaN Example 4: javascript convert string to number or integer //It accepts two arguments. //The first argument is the string to convert. //The second argument is called

Count Occurrences Of Substring In String Javascript Code Example

Example 1: javascript count occurrences in string function countOccurences ( string , word ) { return string . split ( word ) . length - 1 ; } var text = "We went down to the stall, then down to the river." ; var count = countOccurences ( text , "down" ) ; // 2 Example 2: js string includes count /** Function that count occurrences of a substring in a string; * @param { String } string The string * @param { String } subString The sub string to search for * @param { Boolean } [ allowOverlapping ] Optional. (Default:false) * * @author Vitim.us https://gist.github.com/victornpb/7736865 * @see Unit Test https://jsfiddle.net/Victornpb/5axuh96u/ * @see http://stackoverflow.com/questions/4009756/how-to-count-string-occurrence-in-string/7924240#7924240 */ function occurrences ( string , subString , allowOverlapping ) { string += "" ; subString += "" ; if ( subString . length

Convert A String Array To Int Array Python Code Example

Example: convert string array to integer python desired_array = [ int ( numeric_string ) for numeric_string in current_array ]

Blazor Dropdown Select Code Example

Example: blazorstrap dropdown onchange //Your answer should be in the cshtml: < select class = "form-control" @onchange = "@OnSelect" style = "width:150px" > @ foreach ( var template in templates ) { < option value = @template > @template < / option > } < / select > < h5 > Selected Country is : @selectedString < / h5 > //Then your @functions or @code if Blazor should look like: @code { List < string > templates = new List < string > ( ) { "America" , "China" , "India" , "Russia" , "England" } ; string selectedString = "America" ; void OnSelect ( ChangeEventArgs e ) { selectedString = e . Value . ToString ( ) ; Console . WriteLine ( "The selected country is : " + selectedString ) ; } }

Converting Docx To Pdf With Pure Python (on Linux, Without Libreoffice)

Answer : The PythonAnywhere help pages offer information on working with PDF files here: https://help.pythonanywhere.com/pages/PDF Summary: PythonAnywhere has a number of Python packages for PDF manipulation installed, and one of them may do what you want. However, shelling out to abiword seems easiest to me. The shell command abiword --to=pdf filetoconvert.docx will convert the docx file to a PDF and produce a file named filetoconvert.pdf in the same directory as the docx. Note that this command will output an error message to the standard error stream complaining about XDG_RUNTIME_DIR (or at least it did for me), but it still works, and the error message can be ignored. Another one you could use is libreoffice, however as the first responder said the quality will never be as good as using the actual comtypes. anyways, after you have installed libreoffice, here is the code to do it. from subprocess import Popen LIBRE_OFFICE = r"C:\Program Files\LibreOffice\program\soffice

7am Pacific Time To South Africa Code Example

Example: 9 pst to south africa time add 10 hours

Svg Animator Code Example

Example: svg animate <svg viewBox= "0 0 10 10" xmlns= "http://www.w3.org/2000/svg" > <rect width= "10" height= "10" > <animate attributeName= "rx" values= "0;5;0" dur= "10s" repeatCount= "indefinite" /> </rect> </svg>

Correct Syntax To Write Php Code Code Example

Example 1: php hello world echo "Hello World" ; Example 2: php in html Basic PHP Syntax A PHP script can be placed anywhere in the document. A PHP script starts with <?php and ends with ?> : <?php // PHP code goes here ?> The default file extension for PHP files is ".php". A PHP file normally contains HTML tags, and some PHP scripting code. Example <! DOCTYPE html > < html > < body > < h1 > Php in html </ h1 > <?php echo "Hello World!" ; ?> </ body > </ html >

How To Change Text-decoration: Underline Color In Html Code Example

Example: css underline color u { text-decoration : underline ; text-decoration-color : red ; } example of use : ( in html ) <p>The word <u>CAT</u> , is underlined </p>

Convert Microsoft Visio Drawing (vsd) To PDF Automatically

Answer : I found this nice vbs script and adapted it to visio.It can be called via cygwin (works for all kind of Office stuff) Option Explicit Main() Sub Main() If WScript.Arguments.Count > 0 Then Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject") Dim i For i = 0 to wscript.arguments.count - 1 Dim strFilePath : strFilePath = WScript.Arguments.Item(i) Dim dirPath : dirPath = objFSO.GetParentFolderName(strFilePath) Dim fileBaseName : fileBaseName = objFSO.GetBaseName(strFilePath) 'WScript.Echo strFilePath Dim strNewFileName : strNewFileName = dirPath & "\" & fileBaseName & ".pdf" 'WScript.Echo strNewFileName Dim strFileExt : strFileExt = UCase(objFSO.GetExtensionName(strFilePath)) Select Case strFileExt Case "DOC" DOC2PDF strFilePath, strNewFileName Case "

Exponential Operator In Python Code Example

Example 1: exponential python import math math. exp ( x ) Example 2: python math operators # Below follow the math operators that can be used in python # ** Exponent 2 ** 3 # Output : 8 # % Modulus/Remaider 22 % 8 # Output : 6 # // Integer division 22 // 8 # Output : 2 # / Division 22 / 8 # Output : 2.75 # * Multiplication 3 * 3 # Output : 9 # - Subtraction 5 - 2 # Output : 3 # + Addition 2 + 2 # Output : 4

Add Photo To Flutter App Code Example

Example: flutter asset image not showing flutter: uses-material-design: true assets: - assets/ class _UserLoginState extends State { @override Widget build(BuildContext context) { return Scaffold( body: Stack( children: [ Image(image: AssetImage("assets/christmas.jpeg"), fit: BoxFit.cover, ], ) ); } }

Convert A Datetime.timedelta Into ISO 8601 Duration In Python?

Answer : Although the datetime module contains an implementation for a ISO 8601 notation for datetime or date objects, it does not currently (Python 3.7) support the same for timedelta objects. However, the isodate module (pypi link) has functionality to generate a duration string in ISO 8601 notation: In [15]: import isodate, datetime In [16]: print(isodate.duration_isoformat(datetime.datetime.now() - datetime.datetime(1985, 8, 13, 15))) P12148DT4H20M39.47017S which means 12148 days, 4 hours, 20 minutes, 39.47017 seconds. This is a function from Tin Can Python project (Apache License 2.0) that can do the conversion: def iso8601(value): # split seconds to larger units seconds = value.total_seconds() minutes, seconds = divmod(seconds, 60) hours, minutes = divmod(minutes, 60) days, hours = divmod(hours, 24) days, hours, minutes = map(int, (days, hours, minutes)) seconds = round(seconds, 6) ## build date date = '' if days: d

Std Cin Example

Example 1: cin in c++ cin >> varName ; Example 2: c++ cin operator //Akbarali saqlagan C++ bo'yicha cin operatoriga ta'rif # include <iostream> using namespace std ; int main ( ) { int a ; cout << "Kattaroq sonni yozing: " ; cin >> a ; int b ; cout << "Tepadaginga nisbatan kichik bo`lgan son(qiymatni) yozing: " ; cin >> b ; cout << "Birinchi kiritgan soningizdan ikkinchi kiitgan soningiz " << a - b << " marta katta ekanligi ma'lum bo'ldi.\n" ; return 0 ; }

Convertir Youtube A Mp3 Download 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: youtube download mp3 I use https://github.com/ytdl-org/youtube-dl/ as a Python CLI tool to download videos

Create View Join Mysql Code Example

Example 1: create view mysql CREATE VIEW ` general_v_movie_rentals ` AS SELECT mb . ` membership_number ` , mb . ` full_names ` , mo . ` title ` , mr . ` transaction_date ` , mr . ` return_date ` FROM ` movierentals ` AS mr INNER JOIN ` members ` AS mb ON mr . ` membership_number ` = mb . ` membership_number ` INNER JOIN ` movies ` AS mo ON mr . ` movie_id ` = mo . ` movie_id ` ; Example 2: mysql view from multiple tables CREATE VIEW V AS ( SELECT i . country , i . year , p . pop , f . food , i . income FROM INCOME i LEFT JOIN POP p ON i . country = p . country LEFT JOIN Food f ON i . country = f . country WHERE i . year = p . year AND i . year = f . year ) ;

How To Change Input Border Color On Focus Code Example

Example 1: change border highlight color on an input text element input :focus { outline : none !important ; border-color : #719ECE ; box-shadow : 0 0 10 px #719ECE ; } textarea :focus { outline : none !important ; border-color : #719ECE ; box-shadow : 0 0 10 px #719ECE ; } Example 2: change input border color when selected input :focus { outline : none ; border : 1 px solid red ; }

Angular Material 5 - Show Full Text In Mat Lists ( Word Wrap )

Answer : Use the following css: ::ng-deep .mat-list .mat-list-item .mat-line{ word-wrap: break-word; white-space: pre-wrap; } or ::ng-deep .mat-line{ word-wrap: break-word !important; white-space: pre-wrap !important; } Height of mat-list-item is limited to 48px so we need to override in case of large text ::ng-deep .mat-list .mat-list-item{ height:initial!important; } Demo:https://plnkr.co/edit/tTlhYgTkSz1QcgqjCfqh?p=preview Link to know more about the word-wrap and white-spac Simply wrap your whole paragraph inside of <mat-list-item> with <p> tags and that will force correct styles. Makes sense... No need for styles in this case. <mat-list-item> <p> My super long text.......... </p> </mat-list-item> I created this css/scss class. /* CSS */ .mat-list-item.mat-list-item-word-wrap { height: initial !important; } .mat-list-item-word-wrap .mat-line { word-wrap: break-word !imp

Hover Animation In Css Code Example

Example 1: css hover animation .YOURHTMLCONTENT i { height : auto ; float : left ; color : #fff ; font-size : 55 px ; margin : 30 px 30 px 30 px 30 px ; transition : 0.8 s ; transition-property : color , transform ; } .YOURHTMLCONTENT i :hover { color : #FF5733 ; transform : scale ( 1.3 ) ; } Example 2: css transition on hover /* Simple CSS color transition effect on selector */ div { color : white ; background-color : black ; } div :hover { background-color : red ; } /* Additional transition effects on selector */ div { background-color : black ; color : white ; height : 100 px ; transition : width 1.5 s , height 3 s ; width : 100 px ; } div :hover { background-color : red ; height : 300 px ; width : 150 px ; } Example 3: css hover animation a :hover { color : #252525 ; }

Calculating Password Entropy?

Answer : There are equations for when the password is chosen randomly and uniformly from a given set; namely, if the set has size N then the entropy is N (to express it in bits, take the base-2 logarithm of N ). For instance, if the password is a sequence of exactly 8 lowercase letters, such that all sequences of 8 lowercase characters could have been chosen and no sequence was to be chosen with higher probability than any other, then entropy is N = 26 8 = 208827064576 , i.e. about 37.6 bits (because this value is close to 2 37.6 ). Such a nice formula works only as long as uniform randomness occurs, and, let's face it, uniform randomness cannot occur in the average human brain. For human-chosen passwords, we can only do estimates based on surveys (have a look at that for some pointers). What must be remembered is that entropy qualifies the password generation process , not the password itself. By definition, "password meter" applications and Web sites do

Convertir Pdf A Word Code Example

Example 1: pdf to word pdf candy is one of my favourite converter Example 2: convert pdf to word #my opinion pdfcandy.com