Posts

Showing posts from July, 2004

Acid Full Form In Dbms Code Example

Example 1: acid properties in dbms Atomicity The entire transaction take place at once or doesn't happen at all. Consistency Database must be consistent before and after the transaction. Isolation Multiple transactions occur independently without interference. Durability The changes of the successful transaction occurs even if the system failure occur. Example 2: acid properties Atomicity Consistency Isolation Durability

Js Change Background Color Code Example

Example 1: javascript style background color // change background color for specific id .. function changebackground ( ) { document. getElementById ( 'id' ) .style.backgroundColor = 'green' ; } // change background color for whole body.. function changebackground ( ) { document.body.style.backgroundColor = 'green' ; } Example 2: javascript change background color document.body.style.backgroundColor = "yellow" ; Example 3: JavaScript Change Background Color var element = document.body ; element.style.backgroundColor = "blue" ; Example 4: javascript change background color function changeBackground ( color ) { document.body.style.background = color ; } window .addEventListener ( "load" , function ( ) { changeBackground ( 'red' ) } ) ; Example 5: how to change background color using js var warning = document. getElementById ( "warning" ) ; warning.style.background-color = "red" ;

Ahk Auto Clicker Code Example

Example: ahk autoclicker toggle = 0 #MaxThreadsPerHotkey 2 F1:: Toggle := !Toggle While Toggle{ Click sleep 100 } return

Creating A Javascript Function With If Then Statements Code Example

Example: javascript if else var age = 20 ; if ( age < 18 ) { console . log ( "underage" ) ; } else { console . log ( "let em in!" ) ; }

Next Sibling Css Code Example

Example 1: adjacent sibling selector /*The adjacent sibling combinator (+) separates two selectors and matches the second element only if it immediately follows the first element, and both are children of the same parent element.*/ li : first - of - type + li { color : red ; } < ul > < li > One < / li > // The sibling < li > Two < / li > // This adjacent sibling will be red < li > Three < / li > < / ul > Example 2: sibling selector css /*General Sibling*/ /*The general sibling selector selects all elements that are siblings of a specified element. The following example selects all <p> elements that are siblings of <div> elements: */ /*<div></div> <p></p>*/ div ~ p { } /*Adjacent Sibling*/ /*The adjacent sibling selector is used to select an element that is directly after another specific element. Sibling elements must have the same parent element, and "adjace

Conditional Or Ternary Operator In C Code Example

Example 1: how to use ternary operator in c programming int a = 10 , b = 20 , c ; c = ( a < b ) ? a : b ; printf ( "%d" , c ) ; Example 2: ternary operator in c c = ( a < b ) ? a : b ;

Create Or Update Sequelize

Answer : From the docs, you don't need to query where to perform the update once you have the object. Also, the use of promise should simplify callbacks: Implementation function upsert(values, condition) { return Model .findOne({ where: condition }) .then(function(obj) { // update if(obj) return obj.update(values); // insert return Model.create(values); }) } Usage upsert({ first_name: 'Taku' }, { id: 1234 }).then(function(result){ res.status(200).send({success: true}); }); Note This operation is not atomic. Creates 2 network calls. which means it is advisable to re-think the approach and probably just update values in one network call and either: Look at the value returned (i.e. rows_affected) and decide what to do. Return success if update operation succeeds. This is because whether the resource exists is not within this service's responsibility. You can use upsert It

Facebook Icon Font Awesome For Web Code Example

Example: fa fa-facebook < i class = "fa fa-facebook-square" aria - hidden = "true" > < / i >

Angular 2 - Debouncing A KeyUp Event

Answer : UPDATE: Using RXJS 6 pipe operator: this.subject.pipe( debounceTime(500) ).subscribe(searchTextValue => { this.handleSearch(searchTextValue); }); You could create a rxjs/Subject and call .next() on keyup and subscribe to it with your desired debounceTime. I'm not sure if it is the right way to do it but it works. private subject: Subject<string> = new Subject(); ngOnInit() { this.subject.debounceTime(500).subscribe(searchTextValue => { this.handleSearch(searchTextValue); }); } onKeyUp(searchTextValue: string){ this.subject.next(searchTextValue); } HTML: <input (keyup)="onKeyUp(searchText.value)"> An Update for Rx/JS 6. Using the Pipe Operator. import { debounceTime } from 'rxjs/operators'; this.subject.pipe( debounceTime(500) ).subscribe(searchTextValue => { this.handleSearch(searchTextValue); }); Everything else is the same

Hide Inspector Unity Code Example

Example 1: unity hide in inspector using UnityEngine ; public class Example : MonoBehaviour { // Make the variable p not show up in the inspector // but be serialized. [ HideInInspector ] int p = 5 ; } Example 2: unity hide in inspector [ HideInInspector ] public float myVar ;

What Is Logger.getlogger In Python Code Example

Example: from logging import logger # ! / usr / bin / env python3 # - * - coding : UTF - 8 - * - import logging logger = logging . getLogger ( __name__ ) logging . basicConfig ( level = logging . DEBUG ) logger . debug ( 'Loging %s lewel' , 'DEBUG' ) logger . info ( 'Loging %s lewel' , 'INFO' ) logger . warning ( 'Loging %s lewel' , 'WARN' ) logger . error ( 'Loging %s lewel' , 'ERROR' ) logger . critical ( 'Loging %s lewel' , 'CRITICAL' )

Types Of Inheritance Leads To Diamond Problem Code Example

Example: Diamond inheritance The "diamond problem" ( sometimes referred to as the "Deadly Diamond of Death" ) is an ambiguity that arises when two classes B and C inherit from A , and class D inherits from both B and C If there is a method in A that B and C have overridden , and D does not override it , then which class of the method does D inherit : that of B , or that of C ?

How Do I Use Font Space In Css? Code Example

Example 1: letter spacing css div { letter-spacing : 2 px ; } Example 2: kerning css // There is no kerning property , but you can use letter-spacing div { letter-spacing : 2 px ; }

Can I Change Rabbitmq Node Name?

Answer : The following is what should be in the /etc/rabbitmq/rabbitmq-env.conf file (create it): NODENAME=rabbitNodeName@myServerName Next restart RabbitMQ : sudo service rabbitmq-server restart I think yes, you can configure any of this parameters using environment variables, it's described on RabbitMQ configuration page https://www.rabbitmq.com/configure.html

Android Studio "No Tests Were Found"

Answer : Today I had the same problem with some Espresso tests and it was getting me crazy because everything seemed normal. Finally I discovered the problem was because the method annotated with @BeforeClass was throwing an exception. If something goes wrong in that method, the stacktrace of the exception is not shown in the Log window of the Run tab but in the Log window of the Android Monitor tab If you want to reproduce the problem just add this to your testing class: @BeforeClass public static void setupClass() { throw new RuntimeException("Sorry dude, you won't find any test!"); } This can happen when the type of your run configuration is incorrect. With me, this goes wrong when running an Espresso test which used to be a unit test. For some reason it still uses the Android JUnit test configuration when running this test. Manually creating an Android Instrumented Test solves the problem. Just for posterity sakes, here's the solution that worke

Creating A Spiral Array In Python?

Answer : You can build a spiral by starting near the center of the matrix and always turning right unless the element has been visited already: #!/usr/bin/env python NORTH, S, W, E = (0, -1), (0, 1), (-1, 0), (1, 0) # directions turn_right = {NORTH: E, E: S, S: W, W: NORTH} # old -> new direction def spiral(width, height): if width < 1 or height < 1: raise ValueError x, y = width // 2, height // 2 # start near the center dx, dy = NORTH # initial direction matrix = [[None] * width for _ in range(height)] count = 0 while True: count += 1 matrix[y][x] = count # visit # try to turn right new_dx, new_dy = turn_right[dx,dy] new_x, new_y = x + new_dx, y + new_dy if (0 <= new_x < width and 0 <= new_y < height and matrix[new_y][new_x] is None): # can turn right x, y = new_x, new_y dx, dy = new_dx, new_dy else: # try to move straight x, y

Transition Visibility Css Code Example

Example: css transition visibility .m-fadeOut { visibility : hidden ; opacity : 0 ; transition : visibility 0 s linear 300 ms , opacity 300 ms ; } .m-fadeIn { visibility : visible ; opacity : 1 ; transition : visibility 0 s linear 0 s , opacity 300 ms ; }

Can I Use CloudKit On Android Or Web-based App?

Answer : Yes you can. Apple provides CloudKit JS, specifically designed for web services. I don't know much about Android, but I'm pretty sure it'll be not a hard challenge to run JavaScript. Also CloudKit WebServices could be interesting for you. EDIT advice and discussion To give you an honest advice: Better use something "own". I currently work with a custom server on an AWS EC2 instance and am really happy. You could, for example, write a really simple server using Node.js and connect a Mongo DB NoSQL database. CloudKit is actually not more than this. This is really a simple task. I did this before and with some JavaScript experience and a few days Node exercises it is absolutely feasible; you'll write really nice servers very quickly. In the end, when dealing with more customers, CloudKit will be more expensive, actually. And if you, why ever, must move to a different service, you will have trouble with CK, because you are not able t

Css Line Space Code Example

Example 1: line spacing css line-height : 20 px ; /* 4px +12px + 4px */ /* OR */ line-height : 1.7 em ; /* 1em = 12px in this case. 20/12 == 1.666666 */ Example 2: line-height css /* Keyword value */ line-height : normal ; /* Unitless values: use this number multiplied by the element's font size */ line-height : 3.5 ; /* <length> values */ line-height : 3 em ; /* <percentage> values */ line-height : 34 % ; /* Global values */ line-height : inherit ; line-height : initial ; line-height : unset ; Example 3: css line spacing line-height : 1.5 ; /* Prefered */ line-height : 1.5 em ; line-height : 150 % ; line-height : 24 px ; Example 4: line-height css .green { line-height : 1.1 ; border : solid limegreen ; } .red { line-height : 1.1 em ; border : solid red ; } h1 { font-size : 30 px ; } .box { width : 18 em ; display : inline-block ; vertical-align : top ; font-size : 15 px ; } Example 5: line-weight css /* Valeur avec un

List Commands Python Code Example

Example 1: list methods python list . append ( x ) # append x to end of list list . extend ( iterable ) # append all elements of iterable to list list . insert ( i , x ) # insert x at index i list . remove ( x ) # remove first occurance of x from list list . pop ( [ i ] ) # pop element at index i ( defaults to end of list ) list . clear ( ) # delete all elements from the list list . index ( x [ , start [ , end ] ] ) # return index of element x list . count ( x ) # return number of occurances of x in list list . reverse ( ) # reverse elements of list in - place ( no return ) list . sort ( key = None , reverse = False ) # sort list in - place list . copy ( ) # return a shallow copy of the list Example 2: python commands simple python commands print ( "your text here" ) -- -- -- -- -- -- -- -- -- -- -- -- -- -- - name = input ( "what is your name" ) print ( "nice to meet you " + name ) -- -- -- -- -- -- -- -- -- -- -- -

Html Css O Clicked Code Example

Example: css clicked event CSS clicked event :active { css declarations ; }

How To Make Background Image Responsive In Bootstrap 4 Code Example

Example: add background image in bootstrap 5 <div class= "has-bg-img bg-purple bg-blend-screen" > <h4>Background blend mode : Multiply</h4> <img class= "bg-img" src= "..." > </div>