Posts

Showing posts from November, 2014

Css Trick Flex Code Example

Example 1: css flex /* Flex */ .anyclass { display:flex; } /* row is the Default, if you want to change choose */ .anyclass { display:flex; flex-direction: row | row-reverse | column | column-reverse; } .anyclass { /* Alignment along the main axis */ justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe; } Example 2: flex: syntex flex: none /* value 'none' case */ flex: <'flex-grow'> /* One value syntax, variation 1 */ flex: <'flex-basis'> /* One value syntax, variation 2 */ flex: <'flex-grow'> <'flex-basis'> /* Two values syntax, variation 1 */ flex: <'flex-grow'> <'flex-shrink'> /* Two values syntax, variation 2 */ flex: <'flex-grow'> &l

Get Skeleton Cdn Code Example

Example: skeleton css cdn <link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" >

Corporate Login Of Geeksforgeeks Code Example

Example: gfg number of digits in N = log10(N) + 1.

Enum Values In C Code Example

Example 1: a enum data type in c // An example program to demonstrate working // of enum in C # include <stdio.h> enum week { Mon , Tue , Wed , Thur , Fri , Sat , Sun } ; int main ( ) { enum week day ; day = Wed ; printf ( "%d" , day ) ; return 0 ; } // OUTPUT 2 Example 2: how to define a enum in c //enum <name of enumeration> { <possible choices separated by commas> } enum type_of_fuel { Gasolina , Gasoleo , Hibrido , Eletrico } ;

Image Upload Button In Html W3schools Code Example

Example 1: File Upload Button and display file javascript <script src= "https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js" ></script> <form> <label for= "file-upload" class= "custom-file-upload" > <i class= "fa fa-cloud-upload" ></i> Upload Image </label> <input id= "file-upload" name= 'upload_cont_img' type= "file" style= "display:none;" > </form> Example 2: upload button in html <form action= "/action_page.php" > <input type= "file" id= "myFile" name= "filename" > <input type= "submit" > </form>

CSS Fixed Width In A Span

Answer : In an ideal world you'd achieve this simply using the following css <style type="text/css"> span { display: inline-block; width: 50px; } </style> This works on all browsers apart from FF2 and below. Firefox 2 and lower don't support this value. You can use -moz-inline-box, but be aware that it's not the same as inline-block, and it may not work as you expect in some situations. Quote taken from quirksmode ul { list-style-type: none; padding-left: 0px; } ul li span { float: left; width: 40px; } <ul> <li><span></span> The lazy dog.</li> <li><span>AND</span> The lazy cat.</li> <li><span>OR</span> The active goldfish.</li> </ul> Like Eoin said, you need to put a non-breaking space into your "empty" spans, but you can't assign a width to an inline element, only padding/margin so you'll need to make it float so that yo

Complete Python Tutorial By CodeClary Code Example

Example 1: how to learn python """ Great foundation for basics https://www.w3schools.com/python/default.asp" """ Example 2: how to learn python # Basic python sum calculator # If you know how to use function, you can use it, but for starters I will not use it number_first = input("Please input fisrt number: ") # input() is used to take user input number_second = input("Please input second number: ") # input() is used to take user input # There is two way to add two numbers print(sum((number_first, number_second))) # print() used to print stuff. # sum() takes tuple and sum the two or more numbers in it. print(number_first + number_second) # print() used to print stuff. This method is easier and just make you do simple math. ========================================================= # Output: Please input fisrt number: 1 Please input second number: 7 >>> 8 # sum() printed >>> 8 # second method printed Example 3: h

Can Scp Create A Directory If It Doesn't Exist?

Answer : This is one of the many things that rsync can do. If you're using a version of rsync released in the past several years,¹ its basic command syntax is similar to scp :² $ rsync -r local-dir remote-machine:path That will copy local-source and its contents to $HOME/path/local-dir on the remote machine, creating whatever directories are required.³ rsync does have some restrictions here that can affect whether this will work in your particular situation. It won't create multiple levels of missing remote directories, for example; it will only create up to one missing level on the remote. You can easily get around this by preceding the rsync command with something like this: $ ssh remote-host 'mkdir -p foo/bar/qux' That will create the $HOME/foo/bar/qux tree if it doesn't exist. It won't complain or do anything else bad if it does already exist. rsync sometimes has other surprising behaviors. Basically, you're asking it to figure

Quotes In Html Css Code Example

Example: how to add quote in html <p>Anything you'd like to mention goes here : <blockquote> "Insert actual quote here." </blockquote> - Mr. Name</p>

Copy Local File If Exists, Using Ansible

Answer : A more comprehensive answer: If you want to check the existence of a local file before performing some task, here is the comprehensive snippet: - name: get file stat to be able to perform a check in the following task local_action: stat path=/path/to/file register: file - name: copy file if it exists copy: src=/path/to/file dest=/destination/path when: file.stat.exists If you want to check the existence of a remote file before performing some task, this is the way to go: - name: get file stat to be able to perform check in the following task stat: path=/path/to/file register: file - name: copy file if it exists copy: src=/path/to/file dest=/destination/path when: file.stat.exists Change your first step into the following on - name: copy local filetocopy.zip to remote if exists local_action: stat path="../filetocopy.zip" register: result If you don't wont to set up two tasks, you could use 'is file' to check if local files exist

Node Js Database Connection Best Practice Code Example

Example: how to manage a db connection in javascript //put these lines in a seperate file const mysql = require ( 'mysql2' ) ; const connection = mysql .createPool ( { host : "localhost" , user : "" , password : "" , database : "" // here you can set connection limits and so on } ) ; module.exports = connection ; //put these on destination page const connection = require ( '../util/connection' ) ; async function getAll ( ) { const sql = "SELECT * FROM tableName" ; const [rows] = await connection. promise ( ) . query ( sql ) ; return rows ; } exports.getAll = getAll ;

Byte String Vs. Unicode String. Python

Answer : No python does not use its own encoding. It will use any encoding that it has access to and that you specify. A character in a str represents one unicode character. However to represent more than 256 characters, individual unicode encodings use more than one byte per character to represent many characters. bytearray objects give you access to the underlaying bytes. str objects have the encode method that takes a string representing an encoding and returns the bytearray object that represents the string in that encoding. bytearray objects have the decode method that takes a string representing an encoding and returns the str that results from interpreting the bytearray as a string encoded in the the given encoding. Here's an example. >>> a = "αά".encode('utf-8') >>> a b'\xce\xb1\xce\xac' >>> a.decode('utf-8') 'αά' We can see that UTF-8 is using four bytes, \xce, \xb1, \xce, and \xac to repr

How To Take User Input In An String Array In Java Code Example

Example 1: take string array input in java String [ ] array = new String [ 20 ] ; System . out . println ( "Please enter 20 names to sort" ) ; Scanner s1 = new Scanner ( System . in ) ; for ( int i = 0 ; i < 20 ; ) { array [ i ] = s1 . nextLine ( ) ; } Example 2: how to get array input in java public class TakingInput { public static void main ( String [ ] args ) { Scanner s = new Scanner ( System . in ) ; System . out . println ( "enter number of elements" ) ; int n = s . nextInt ( ) ; int arr [ ] = new int [ n ] ; System . out . println ( "enter elements" ) ; for ( int i = 0 ; i < n ; i ++ ) { //for reading array arr [ i ] = s . nextInt ( ) ; } for ( int i : arr ) { //for printing array System . out . println ( i ) ; } } }

CSS Force Image Resize And Keep Aspect Ratio

Answer : img { display: block; max-width:230px; max-height:95px; width: auto; height: auto; } <p>This image is originally 400x400 pixels, but should get resized by the CSS:</p> <img width="400" height="400" src="http://i.stack.imgur.com/aEEkn.png"> This will make image shrink if it's too big for specified area (as downside, it will not enlarge image). I've struggled with this problem quite hard, and eventually arrived at this simple solution: object-fit: cover; width: 100%; height: 250px; You can adjust the width and height to fit your needs, and the object-fit property will do the cropping for you. More information about the possible values for the object-fit property and a compatibility table are available here: https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit Cheers. The solutions below will allow scaling up and scaling down of the image , depending on the parent box width. All images have a parent cont

Connect Speaker Output To Microphone Input

Answer : Better make R2 switchable or variable with 1k being the upper limit. But the basic approach is probably OK. Speaker signals are relatively high voltage and relatively low impedance (meaning they can deliver a lot of current). What that means depends on the speaker; anything from a couple of volts and a fraction of an amp (total power 0.25 watts or so) for a little multimedia speaker up to tens of thousands of watts for an AC/DC gig... Microphones are delicate devices delivering millivolts into a high impedance input (low current, very low power). So you need to attenuate the speaker output (reduce the voltage) to avoid overloading the microphone input. The circuit you provided will protect it from damage, but it might still overload enough to distort the input signal. HOWEVER if you are referring to the coloured connectors shown, the green one is "Line Out" - 0.1 to 0.5V rms, not enough power to drive a speaker directly; a lot of PC speakers have amplifiers built

C# Linq Select Where In List Code Example

Example 1: c# linq select from object list // this will return the first correct answer, // or throw an exception if there are no correct answers var correct = answers . First ( a = > a . Correct ) ; // this will return the first correct answer, // or null if there are no correct answers var correct = answers . FirstOrDefault ( a = > a . Correct ) ; // this will return a list containing all answers which are correct, // or an empty list if there are no correct answers var allCorrect = answers . Where ( a = > a . Correct ) . ToList ( ) ; Example 2: linq where in list var allowedStatus = new [ ] { "A" , "B" , "C" } ; var filteredOrders = orders . Order . Where ( o = > allowedStatus . Contains ( o . StatusCode ) ) ; Example 3: linq query select where c# var queryLondonCustomers = from cust in customers where cust . City = = "London" select cust

Convert String To Int In Js 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: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42 let myNumber = Number ( "5.25" ) ; //5.25 Example 5: javas

Find 25% Of 100 In C# Code Example

Example 1: percentage in c# number = ( percentage / 100 ) * totalNumber ; Example 2: percentage in c# percentage = ( yourNumber / totalNumber ) * 100 ;