Posts

Showing posts from November, 2010

Aggregation Vs Composition Vs Association Vs Direct Association

Image
Answer : Please note that there are different interpretations of the "association" definitions. My views below are heavily based on what you would read in Oracle Certification books and study guides. Temporary association A usage inside a method , its signature or as a return value. It's not really a reference to a specific object. Example: I park my Car in a Garage. Composition association A so-called " STRONG relationship ": The instantiation of the linked object is often hard coded inside the constructor of the object. It cannot be set from outside the object. (Composition cannot be a many-to-many relationship.) Example: A House is composed of Stones. Direct association This is a " WEAK relationships ". The objects can live independent and there are usually setters or other ways to inject the dependent objects. Example: A Car can have Passengers. Aggregation association Very similar to a Direct as

Docker Restart Always Code Example

Example 1: docker restart sudo systemctl restart docker Example 2: docker run restart always $ docker run --restart =always redis Example 3: docker run restart on boot $ docker run -d --restart unless-stopped <image> Example 4: docker how to restart container at coputer startup docker run -d --restart unless-stopped -p27017 : 27017 mongo Example 5: docker machine keep restarting # first step is checking the docker logs like this docker logs --tail 50 --follow --timestamps <machine_name>

An Application To Easily Pick A Color In Mac OS X And Get The Hex Value

Image
Answer : OS X comes with DigitalColor Meter: Applications > Utilities > DigitalColor Meter.app It has many options and preferences. command+shift+c will copy the color under the cursor to the clipboard in many different formats. The Mac OS X color picker is extensible. Use Hex Color Picker to add a tab that provides you the configured color in hexadecimal RGB. Just run e.g. TextEdit and press Cmd-Shift-C to open the color picker, or run your standalone program. An even more versatile color picker is Developer Color Picker with many different output formats, one of which is hexadecimal. This is easily done with AppleScript. A complete working example of code is available here.

%lu In C Code Example

Example: double data type format in c % lf you can try

Calling Private Function Within The Same Class Python

Answer : There is no implicit this-> in Python like you have in C/C++ etc. You have to call it on self . class Foo: def __bar(self, arg): #do something def baz(self, arg): self.__bar(arg) These methods are not really private though. When you start a method name with two underscores Python does some name mangling to make it "private" and that's all it does, it does not enforce anything like other languages do. If you define __bar on Foo , it is still accesible from outside of the object through Foo._Foo__bar . E.g., one can do this: f = Foo() f._Foo__bar('a') This explains the "odd" identifier in the error message you got as well. You can find it here in the docs. __bar is "private" (in the sense that its name has been mangled), but it's still a method of Foo , so you have to reference it via self and pass self to it. Just calling it with a bare __bar() won't work; you have to call i

C++ Program To Find Gcd Of 3 Numbers Code Example

Example: c++ program to find gcd of 3 numbers #include<stdio.h> int main ( ) { int a , b , c , hcf , st ; printf ( "Enter three numbers : " ) ; scanf ( "%d,%d,%d" , & a , & b , & c ) ; st = a < b? ( a < c?a : c ) : ( b < c?b : c ) ; for ( hcf = st ; hcf >= 1 ; hcf - - ) { if ( a % hcf == 0 & & b % hcf == 0 & & c % hcf == 0 ) break ; } printf ( "%d" , hcf ) ; return 0 ; }

Connection String For Mongodb Localhost Database Url Code Example

Example 1: mongodb local connection string mongodb : / / localhost : 27017 / mydbname Example 2: can we replace a mongouri string with localhost mongodb : / / mongodb0 . example . com : 27017

How To Find Size Of A Dynamic Array C Code Example

Example: how to dynamically allocate array size in c // declare a pointer variable to point to allocated heap space int * p_array ; double * d_array ; // call malloc to allocate that appropriate number of bytes for the array p_array = ( int * ) malloc ( sizeof ( int ) * 50 ) ; // allocate 50 ints d_array = ( int * ) malloc ( sizeof ( double ) * 100 ) ; // allocate 100 doubles // use [] notation to access array buckets // (THIS IS THE PREFERED WAY TO DO IT) for ( i = 0 ; i < 50 ; i ++ ) { p_array [ i ] = 0 ; } // you can use pointer arithmetic (but in general don't) double * dptr = d_array ; // the value of d_array is equivalent to &(d_array[0]) for ( i = 0 ; i < 50 ; i ++ ) { * dptr = 0 ; dptr ++ ; }

Connect To Firebase Database Through Firebase Cli Code Example

Example 1: firebase cli windows npm install -g firebase-tools Example 2: firebase tools install installing firebase tools

Csgo Jump Throw Bind Code Example

Example: csgo jump throw bind alias "+jumpthrow" "+jump;-attack"; alias "-jumpthrow" "-jump"; bind alt "+jumpthrow"

Rotate Text CSS Animation Code Example

Example 1: rotate text css .text { /* Browsers not below */ transform : rotate ( -90 deg ) ; /* Safari */ -webkit-transform : rotate ( -90 deg ) ; /* Firefox */ -moz-transform : rotate ( -90 deg ) ; /* Opera */ -o-transform : rotate ( -90 deg ) ; /* IE */ -ms-transform : rotate ( -90 deg ) ; } Example 2: css rotate text /* Answer to: "css rotate text" */ /* If what you are looking for is a way to set type vertically, you’re best bet is probably CSS writing-mode, here's a link: https://css-tricks.com/almanac/properties/w/writing-mode/ If you’re just trying to turn some text, you can rotate entire elements like this, which rotates it 90 degrees counterclockwise: */ .rotate { transform : rotate ( -90 deg ) ; /* Legacy vendor prefixes that you probably don't need... */ /* Safari */ -webkit-transform : rotate ( -90 deg ) ; /* Firefox */ -moz-transform : rotate ( -90 deg ) ; /* IE */ -ms-transform : rotate ( -90 de

Android Change Include Layout Programmatically Code Example

Example 1: code to include layout from java in android < ViewStub android : id = "@+id/layout_stub" android : inflatedId = "@+id/message_layout" android : layout_width = "match_parent" android : layout_height = "match_parent" android : layout_weight = "0.75" / > Example 2: code to include layout from java in android ViewStub stub = ( ViewStub ) findViewById ( R . id . layout_stub ) ; stub . setLayoutResource ( R . layout . whatever_layout_you_want ) ; View inflated = stub . inflate ( ) ;

Linked List C Openclassroom Code Example

Example 1: liste chainée c typedef struct Element Element ; struct Element { int nombre ; Element * suivant ; } ; Example 2: liste chainée c typedef struct Liste Liste ; struct Liste { Element * premier ; } ;

Convert Json String To Dict Python Code Example

Example 1: python json to dict import json # with json.loads (string) info = '{"name": "Dave","City": "NY"}' res = json . loads ( info ) print ( res ) print ( "Datatype of the serialized JSON data : " + str ( type ( res ) ) ) #>>> {'name': 'Dave', 'City': 'NY'} #>>> Datatype of the serialized JSON data : <class 'dict'> # with json load (file) info = open ( 'data.json' , ) res = json . load ( info ) print ( res ) print ( "Datatype after deserialization : " + str ( type ( res ) ) ) #>>> {'name': 'Dave', 'City': 'NY'} #>>> Datatype of the serialized JSON data : <class 'dict'> Example 2: python dict to json # app.py import json appDict = { 'name' : 'messenger' , 'playstore' : True , 'company' : 'Facebook' , 'price

Javascript Get Screen Height Code Example

Example 1: get window size javascript const window { width : window.innerWidth , height : window.innerHeight } Example 2: get screen width javascript window.screen.width //or just screen.width Example 3: how to get the size of the window in javascript var win = window , doc = document , docElem = doc.documentElement , body = doc. getElementsByTagName ( 'body' ) [ 0 ] , x = win.innerWidth || docElem.clientWidth || body.clientWidth , y = win.innerHeight|| docElem.clientHeight|| body.clientHeight ; alert ( x + ' × ' + y ) ; Example 4: get window height javascript <p id= "demo" ></p> <script> document. getElementById ( "demo" ) .innerHTML = "Screen width is " + screen.width ; </script>