Posts

Showing posts from November, 2004

Bootstrap Loading Spinner Full Screen Code Example

Example: bootstrap spinner/ loader < div class = " spinner-border " > </ div >

365 Factorial Code Example

Example: calculate factorial int factorial ( int n ) { int res = 1 , i ; for ( i = 2 ; i <= n ; i ++ ) res *= i ; return res ; }

Queryselector Jquery Code Example

Example 1: queryselector var el = document. querySelector ( ".myclass" ) ; Example 2: jquery from object to queryselector $ ( "#foo" ) [ 0 ] ; // Equivalent to document. getElementById ( "foo" ) or document. querySelector ( '#foo' ) $ ( "#foo" ) . get ( 0 ) ; // Identical to above , only slower. Example 3: javascript queryselector //Pretend there is a <p> with class "example" const myParagraph = document. querySelector ( '.example' ) ; //You can do many this with is myParagraph.textContent = 'This is my new text' ; Example 4: queryselector for jquery var x = $ ( ".yourclass" ) [ 0 ] ; console. log ( 'jq' + x ) ; var y = document. querySelector ( ".yourclass" ) ; console. log ( 'js' + y ) ; Example 5: queryselector function in javascript /*The querySelector() method returns the first element that matches a specified CSS selector(s) in the document. Note

Create PostgreSQL ROLE (user) If It Doesn't Exist

Answer : Simplify in a similar fashion to what you had in mind: DO $do$ BEGIN IF NOT EXISTS ( SELECT FROM pg_catalog.pg_roles -- SELECT list can be empty for this WHERE rolname = 'my_user') THEN CREATE ROLE my_user LOGIN PASSWORD 'my_password'; END IF; END $do$; (Building on @a_horse_with_no_name's answer and improved with @Gregory's comment.) Unlike, for instance, with CREATE TABLE there is no IF NOT EXISTS clause for CREATE ROLE (up to at least pg 12). And you cannot execute dynamic DDL statements in plain SQL. Your request to "avoid PL/pgSQL" is impossible except by using another PL. The DO statement uses plpgsql as default procedural language. The syntax allows to omit the explicit declaration: DO [ LANGUAGE lang_name ] code ... lang_name The name of the procedural language the code is written in. If omitted, the default is plpgsql . The accepted answer suffers from a race condition if two such scripts

Android Attaching A File To GMAIL - Can't Attach Empty File

Answer : Ok, got it to work now, after a lot of research and intercepting some Intents. What I had to do was change the file:/// to content://. I did this following this information from Android: https://developer.android.com/reference/android/support/v4/content/FileProvider.html The only major change was that I used a hard-coded path to /sdcard/file.ext. Also, the line getUriForFile(getContext(), "com.mydomain.fileprovider", newFile); was changed to Uri contentUri = FileProvider.getUriForFile(this, "com.mydomain.fileprovider", newFile); Also had to include: intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); i.setData(contentUri); I do not really understand why I had to change from File to Content , but after this, the file is now being attached again! See the link if you face this issue, and don't forget about the new .xml that needs to be created. See the following question:

Abstraction Synonym Code Example

Example 1: what is abstraction it is process of hiding implementation details and only showing the functionality to the user. Abstraction focus on what the object does instead of how it does. It is achieved by using Abstract class and Interface. abstract methods (methods without body, cannot be static and final), interface must implemented and abstract classes must be extended by regular classes in order to achieve abstraction (because abstract methods can only be exist in abstract class and interface). A class can implement multiple interfaces, but it can extend only single abstract class. Ex: In my framework I have achieve abstraction by using collections or Map, because it’s all interface. Most of the cases I come across using List. If we want to access elements frequently by using index, List is a way to go. ArrayList provides faster access if we know index. If we want to store elements and want them to maintain an order, List is a better choice. i)List < Str

Anaconda Python Spyder Download Code Example

Example: download spyder without anaconda 1 . python -m pip install pyqt5 2 . python -m pip install spyder 3 . python -m pip install PyQtWebEngine 4 . spyder3 ( to launch spyder )

Put Background Image Without Css Javascript Code Example

Example: js background image document.body.style.backgroundImage = "url('img_tree.png')" ;

Dark Purple Color Code Code Example

Example: rgb purple color ( 128 , 0 , 128 ) Hex #800080

C++ Std::atomic::load

(since C++11) T load( std::memory_order order = std::memory_order_seq_cst ) const noexcept; T load( std::memory_order order = std::memory_order_seq_cst ) const volatile noexcept; Atomically loads and returns the current value of the atomic variable. Memory is affected according to the value of order . order must be one of std::memory_order_relaxed , std::memory_order_consume , std::memory_order_acquire or std::memory_order_seq_cst . Otherwise the behavior is undefined. Parameters order - memory order constraints to enforce Return value The current value of the atomic variable. See also operator T loads a value from an atomic object (public member function) atomic_load atomic_load_explicit (C++11) (C++11) atomically obtains the value stored in an atomic object (function template)

60 Inch To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

$spacer Bootstrap Code Example

Example 1: bootstrap Margin and padding Use the margin and padding spacing utilities to control how elements and components are spaced and sized. Bootstrap 4 includes a five-level scale for spacing utilities , based on a 1 rem value default $spacer variable. Choose values for all viewports ( e.g. , .mr-3 for margin-right : 1 rem ) , or pick responsive variants to target specific viewports ( e.g. , .mr-md-3 for margin-right : 1 rem starting at the md breakpoint ) . <div class= "my-0 bg-warning" >Margin Y 0 </div> <div class= "my-1 bg-warning" >Margin Y 1 </div> <div class= "my-2 bg-warning" >Margin Y 2 </div> <div class= "my-3 bg-warning" >Margin Y 3 </div> <div class= "my-4 bg-warning" >Margin Y 4 </div> <div class= "my-5 bg-warning" >Margin Y 5 </div> <div class= "my-auto bg-warning" >Margin Y Auto</div> Examp

Angular Http - ToPromise Or Subscribe

Answer : If you like the reactive programming style and want to be consistent within your application to always use observables even for single events (instead of streams of events) then use observables. If that doesn't matter to you, then use toPromise() . One advantage of observables is, that you can cancel the request. See also Angular - Promise vs Observable I think as long as the response is not a data stream that you're going to use, then you'd better use the .toPromise() approach, because it's meaningless to keep listening to a response that you don't need and it's not even going to change.

Css Media Queries Mdn Code Example

Example: media query in html style span { background-image: url(particular_ad.png); } @media (max-width: 300px) { span { background-image: url(particular_ad_small.png); } }

Abstraction Example In Java

Example 1: abstract class in java Sometimes we may come across a situation where we cannot provide implementation to all the methods in a class. We want to leave the implementation to a class that extends it. In such case we declare a class as abstract.To make a class abstract we use key word abstract. Any class that contains one or more abstract methods is declared as abstract. If we don’t declare class as abstract which contains abstract methods we get compile time error. 1)Abstract classes cannot be instantiated 2)An abstarct classes contains abstract method, concrete methods or both. 3)Any class which extends abstarct class must override all methods of abstract class 4)An abstarct class can contain either 0 or more abstract method. Example 2: abstraction in java Abstraction is defined as hiding internal implementation and showing only necessary information. // abstract class abstract class Addition { // abstract methods public abstract int addTwoNum

Grey In Rgba Code Example

Example 1: grey rgb values #808080 rgb ( 128 , 128 , 128 ) Example 2: grey rgb RGB ( 220 , 220 , 220 )

Python Logging To File And Stdout Code Example

Example 1: python logging to file import logging import sys logger = logging . getLogger ( ) logger . setLevel ( logging . INFO ) formatter = logging . Formatter ( '%(asctime)s | %(levelname)s | %(message)s' , '%m-%d-%Y %H:%M:%S' ) stdout_handler = logging . StreamHandler ( sys . stdout ) stdout_handler . setLevel ( logging . DEBUG ) stdout_handler . setFormatter ( formatter ) file_handler = logging . FileHandler ( 'logs.log' ) file_handler . setLevel ( logging . DEBUG ) file_handler . setFormatter ( formatter ) logger . addHandler ( file_handler ) logger . addHandler ( stdout_handler ) Example 2: python logging to file import logging "" " DEBUG INFO WARNING ERROR CRITICAL "" " # asctime : time of the log was printed out # levelname : name of the log # datefmt : format the time of the log # give DEBUG log logging . basicConfig ( format = '%(asctime)s %(levelnam

20cm To Inches Code Example

Example 1: cm to inch 1 cm = 0.3937 inch Example 2: cm to inches 1 cm = 0.393701 inch Divide the cm value by 2.54. Example 3: cm to inches const cm = 1; console.log(`cm:${cm} = in:${cmToIn(cm)}`); function cmToIn(cm){ var in = cm/2.54; return in; }

Void Meaning In C Code Example

Example 1: what is void in c FUNCTION DECLARATION when void is used as a function return type , it indicates that the function does not return a value . POINTER DECLERATION When void appears in a pointer declaration , it specifies that the pointer is universal . FUNCTION PARAMETER ( IN C ONLY ) When used in a function ' s parameter list , void indicates that the function takes no parameters . Example 2: void c programming FUNCTION DECLARATION when void is used as a function return type , it indicates that the function does not return a value . POINTER DECLERATION When void appears in a pointer declaration , it specifies that the pointer is universal .