Posts

Showing posts from February, 2012

Linear Gradient W3schools Code Example

Example 1: css linear gradient #grad { background-image : linear-gradient ( to right , #f1b1b1 , #82e6e8 ) ; } Example 2: html css background linear-gradient background : linear-gradient ( #333 , #333 50 % , #eee 100 % ) ; \\code for a basic gradient background #grad { background-image : linear-gradient ( red , yellow ) ; } Example 3: html css background linear-gradient #background { background-image : linear-gradient ( to left , #4B2C4C , #151F28 ) ; }

Angular7 And NgbModal: How To Remove Default Auto Focus

Answer : The focus is needed to be within modal for accessibility and keyboard navigation reasons. By default the focus is on the first focusable element within modal, which in your case is the close button. You can add ngbAutofocus attribute to the element where you want the focus to be. Focus management demo. <button type="button" ngbAutofocus class="btn btn-danger" (click)="modal.close('Ok click')">Ok</button> You can read more on github If you don't mind the close button actually focused but want to get rid of the ugly outline, you can use outline: none . template.html : <button type="button" aria-label="Close">Close</button> styles.css : button[aria-label="Close"]:focus { outline: none; } It's an ugly hack, but you can add a non visible element as the first element: <input type="text" style="display:none" />

Latex Blank Line Between Paragraphs Code Example

Example: latex space between paragraphs and lines \setlength { \parindent } { 4 em } \setlength { \parskip } { 1 em } \renewcommand { \baselinestretch } { 1.5 }

Cache Network Image Provider Flutter Code Example

Example: flutter cached network image not working Worked for me after searching all over the sites :=> 1. Install the latest dependency for cached_network_image: 2. Stop and Restart the app if you are debugging or running If not goahead with other steps: 3. Flutter clean 4. Quite from IDE 5. Reopen your IDE and run pub get Example: CachedNetworkImage( imageUrl: 'https://picsum.photos/250?image=9', fit: BoxFit.cover, width: MediaQuery.of(context).size.width, placeholder: (context,url) => CircularProgressIndicator(), errorWidget: (context,url,error) => new Icon(Icons.error), ) ###### OR ###### Image(image: CachedNetworkImageProvider('https://picsum.photos/250?image=9'))

Div Element In Css Code Example

Example 1: how to make a div in html <div class= "myDiv" > <h2>This is a heading in a div element</h2> <p>This is some text in a div element.</p> </div> Example 2: html div //div tag <div> //content </div> //a div is an invisible box

ACE Editor Autocomplete - Custom Strings

Answer : you need to add a completer like this var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; })); } } langTools.setCompleters([staticWordCompleter]) // or editor.completers = [staticWordCompleter] If you want to persist the old keyword list and want to append a new list var staticWordCompleter = { getCompletions: function(editor, session, pos, prefix, callback) { var wordList = ["foo", "bar", "baz"]; callback(null, [...wordList.map(function(word) { return { caption: word, value: word, meta: "static" }; }), ...ses

Entity Framework Update Child Collection Code Example

Example: entity framework update child records public void Update ( UpdateParentModel model ) { var existingParent = _dbContext . Parents . Where ( p => p . Id == model . Id ) . Include ( p => p . Children ) . SingleOrDefault ( ) ; if ( existingParent != null ) { // Update parent _dbContext . Entry ( existingParent ) . CurrentValues . SetValues ( model ) ; // Delete children foreach ( var existingChild in existingParent . Children . ToList ( ) ) { if ( ! model . Children . Any ( c => c . Id == existingChild . Id ) ) _dbContext . Children . Remove ( existingChild ) ; } // Update and Insert children foreach ( var childModel in model . Children ) { var existingChild = existingParent . Children . Where ( c => c . Id == childModel . Id ) . SingleOrDefault ( ) ; if

Convert Excel Column Alphabet (e.g. AA) To Number (e.g., 25)

Answer : Try: var foo = function(val) { var base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', i, j, result = 0; for (i = 0, j = val.length - 1; i < val.length; i += 1, j -= 1) { result += Math.pow(base.length, j) * (base.indexOf(val[i]) + 1); } return result; }; console.log(['A', 'AA', 'AB', 'ZZ'].map(foo)); // [1, 27, 28, 702] solution 1: best performance and browser compatibility // convert A to 1, Z to 26, AA to 27 function lettersToNumber(letters){ var chrs = ' ABCDEFGHIJKLMNOPQRSTUVWXYZ', mode = chrs.length - 1, number = 0; for(var p = 0; p < letters.length; p++){ number = number * mode + chrs.indexOf(letters[p]); } return number; } solution 2: best performance and compatibility and shorter code (Recommended) // convert A to 1, Z to 26, AA to 27 function lettersToNumber(letters){ for(var p = 0, n = 0; p < letters.length; p++){ n = letters[p].charCodeAt() - 64 + n * 26; } return n

Android Can't Record Video With Front Facing Camera, MediaRecorder Start Failed: -19

Answer : I wrestled with this problem a bit today, too. First, make sure that your permissions are set up correctly. Specifically, to record video, you'll want: <uses-feature android:name="android.hardware.camera.front" /> <uses-feature android:name="android.hardware.microphone"/> <uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> Second, and this is the tricky part, this line from the tutorial does not work with the front-facing camera! mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH)); That signature for CamcorderProfile.get() defaults to a profile for the back-facing camera: Returns the camcorder profile for the first back-facing camera on the device at the given quality level. If the device has n

Short Int In C++ Code Example

Example: range of long long in c++ Long Data Type Size ( in bytes ) Range long int 4 - 2 , 147 , 483 , 648 to 2 , 147 , 483 , 647 unsigned long int 4 0 to 4 , 294 , 967 , 295 long long int 8 - ( 2 ^ 63 ) to ( 2 ^ 63 ) - 1 unsigned long long int 8 0 to 18 , 446 , 744 , 073 , 709 , 551 , 615

Android - Can Thief Unlock Stolen Phone That Was Locked By Android Device Manager?

Answer : The answer is almost certainly yes. Someone could probably get past it in one way or another. (They could probably just use odin on a samsung device for example. Though I have never done something like that myself.) If you have sensitive data on there then a remote wipe might be the best thing. Did you report it stolen with your carrier? They could report the ESN / IMEI as stolen so at the very least the thief probably wouldn't be able to sell it. Of course I do not know your exact situation. If you know for sure it was stolen and not lost could the police recover it from the thief? Either way best of luck to you. It would depend on the phone, but as firesoul453 said in his answer, almost certainly yes. Locking the phone is intended to protect the data - In other words: the thief cannot get your data off of the phone. Due to the nature of the android system though, it's usually very easy to wipe out the data on the phone. Usually this can be done via r

Input Type=textarea Code Example

Example 1: html textarea <textarea id= "txtid" name= "txtname" rows= "4" cols= "50" maxlength= "200" > A nice day is a nice day. Lao Tseu </textarea> Example 2: syntax is being placed in my textarea in html <textarea name= "comment" rows= "5" cols= "100" ></textarea></br></br> Example 3: textarea <textarea></textarea> Example 4: html input textarea Check this : https : //codepen.io/DevLorenzo/pen/wvzNPKz Example 5: form::textarea { !! Form : : textarea ( 'placeOfDeath' , null , [ 'class' => 'form-control' , 'rows' => 2 , 'cols' => 40 ] ) !! }

Latex Maketitle Add Spacing Code Example

Example: spacing lines latex \usepackage { setspace } \doublespacing

Brackeys Unity Code Example

Example 1: brackeys brackeys is god Example 2: brackeys Good choice, yes yes

Animation Play Unity Script Code Example

Example 1: how to play animation with code in unity public GameObject ExampleNPC ; void Update ( ) { if ( Input . GetButtonDown ( "Animation" ) ) // Make sure to refrence this in Input settings { ExampleNPC . GetComponent < Animator > ( ) . Play ( "Anim name" ) ; } } Example 2: play animation through script unity animator . Play ( "StateName" ) ;

C++ Vector Pop Front Code Example

Example 1: c++ vector pop first element std :: vector < int > vect ; vect . erase ( vect . begin ( ) ) ; Example 2: vector erase specific element vector . erase ( vector . begin ( ) + 3 ) ; // Deleting the fourth element Example 3: delete from front in vector c++ // Deleting first element vector_name . erase ( vector_name . begin ( ) ) ; // Deleting xth element from start vector_name . erase ( vector_name . begin ( ) + ( x - 1 ) ) ; // Deleting from the last vector_name . pop_back ( ) ; Example 4: vector erase specific element template < typename T > void remove ( std :: vector < T > & vec , size_t pos ) { std :: vector < T > :: iterator it = vec . begin ( ) ; std :: advance ( it , pos ) ; vec . erase ( it ) ; }

Conditional Classname In React Js Code Example

Example 1: react conditional classname < div className = { `banner $ { active ? "active" : "" } ` } > { children } < / div > Example 2: react add class conditionally < div className = { `btn - group pull - right $ { this . props . showBulkActions ? 'shown' : 'hidden' } ` } > Example 3: react conditional class < div className = { "btn-group pull-right " + ( this . props . showBulkActions ? 'show' : 'hidden' ) } > Example 4: conditional classname prop react < span className = { todo . completed ? "true" : "" } >

Curl Https://jsonplaceholder.typicode.com/users/2 Code Example

Example 1: json placeholder fetch ( 'https://jsonplaceholder.typicode.com/todos/1' ) . then ( response => response. json ( ) ) . then ( json => console. log ( json ) ) Example 2: json placeholder api fetch ( 'https://jsonplaceholder.typicode.com/todos/1' ) . then ( response => response. json ( ) ) . then ( json => console. log ( json ) )

Create New Project Angular Code Example

Example 1: create angular project //Author:Mohammad Arman Khan //Steps to install ANGULAR CLI 1 : npm install -g @angular/cli //Initialize first project 2 : ng new my-dream-app 3 : cd my-dream-app // To Run Server 4 : ng serve //done ! ! Example 2: setup new angular project /* Setting up new angular project and run on browser */ npm install -g @angular/cli ng new project-name cd project-name ng serve /* I hope it will help you. Namaste */ Example 3: setup new angular project npm install -g @angular/cli ng new project-name cd project-name ng serve Example 4: angular new project ng new project_name Example 5: ng new project content_copy ng new angular-tour-of-heroes Example 6: create new project angular ng new //After this you will be given the choice to name the project, add routing, add scss/sass/css ng new angular_project cd angular-project ng serve

403 Access Denied On Tomcat 8 Manager App Without Prompting For User/password

Answer : This may be work. Find the CATALINA_HOME/webapps/manager/META-INF/context.xml file and add the comment markers around the Valve. <Context antiResourceLocking="false" privileged="true" > <!-- <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" /> --> </Context> You can find more details at this page. The solution that worked for me is edit context.xml files in both $CATALINA_HOME/webapps/manager/META-INF and $CATALINA_HOME/webapps/host-manager/META-INF where my ip is 123.123.123.123 . <Context antiResourceLocking="false" privileged="true" > <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1|123.123.123.123" /> </Context> I installed Tomcat 8.5 on Ubuntu and edited $CATALINA_HOME/conf/tomcat-users.xml : <role ro

Gold Color Rgb Code Example

Example: rgb gold color ( 255 , 215 , 0 ) /*gold*/ Hex #FFD700

Angular 10 Route Params Code Example

Example 1: angular router with wuery param goProducts ( ) { this . router . navigate ( [ '/products' ] , { queryParams : { order : 'popular' } } ) ; } http : / / localhost : 4200 / products ? order = popular constructor ( private route : ActivatedRoute ) { } ngOnInit ( ) { this . route . queryParams . filter ( params => params . order ) . subscribe ( params => { console . log ( params ) ; // { order: "popular" } this . order = params . order ; console . log ( this . order ) ; // popular } ) ; } Example 2: home page routing in angular const routes : Routes = [ { path : 'home_page_path' , component : HomePageComponent } ] ; add this in app routing file /* I Hope it will Help You. Namaste _/\_ */ Example 3: angular routing url params const appRoutes : Routes = [ { path : 'crisis-center/:param1' , component : CrisisListC

Alter Charset And Collation In All Columns In All Tables In MySQL

Answer : Solution 1: First of all, don't just take my word for it! Test my suggestion out with this: select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' charset=utf8;') from information_schema.TABLES WHERE TABLE_SCHEMA != 'information_schema' limit 10; select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' alter column ',COLUMN_NAME,' charset=utf8;') from information_schema.COLUMNS WHERE TABLE_SCHEMA != 'information_schema' limit 10; If you feel good with the outcome of that, remove the limit clauses and save the output to an SQL script or, get fancy and pipe the output directly to mysql similar to what I demonstrate here. That would look like this: mysql -B -N --host=prod-db1 --user=admin --password=secret -e "select CONCAT('alter table ',TABLE_SCHEMA,'.',TABLE_NAME,' charset=utf8;') from information_schema.TABLES WHERE TABLE_SCHEMA != 'information_schema&#

Erase String C++ Code Example

Example 1: string erase character c++ # include <iostream> # include <algorithm> # include <string> int main ( ) { std :: string s = "This is an example" ; std :: cout << s << '\n' ; s . erase ( 0 , 5 ) ; // Erase "This " std :: cout << s << '\n' ; s . erase ( std :: find ( s . begin ( ) , s . end ( ) , ' ' ) ) ; // Erase ' ' std :: cout << s << '\n' ; s . erase ( s . find ( ' ' ) ) ; // Trim from ' ' to the end of the string std :: cout << s << '\n' ; } Example 2: erase string c++ string & erase ( size_t pos = 0 , size_t len = npos ) ; /* pos Position of the first character to be erased. If this is greater than the string length, it throws out_of_range. Note: The first character in str is denoted by a value of 0 (not 1). len Number of characters to er

Javascript Queryselector Attribute Code Example

Example 1: queryselector name attribute document. querySelectorAll ( '[property]' ) ; // All with attribute named "property" document. querySelectorAll ( '[property="value"]' ) ; // All with "property" set to "value" exactly. Example 2: queryselector function in javascript /*The querySelector() method returns the first element that matches a specified CSS selector(s) in the document. Note: The querySelector() method only returns the first element that matches the specified selectors. To return all the matches, use the querySelectorAll() method instead.*/ // for example //for class document. querySelector ( ".ClassName" ) // for id document. querySelector ( "#ID" ) // etc.

Calculate Exponential Moving Average In Python

Answer : EDIT: It seems that mov_average_expw() function from scikits.timeseries.lib.moving_funcs submodule from SciKits (add-on toolkits that complement SciPy) better suits the wording of your question. To calculate an exponential smoothing of your data with a smoothing factor alpha (it is (1 - alpha) in Wikipedia's terms): >>> alpha = 0.5 >>> assert 0 < alpha <= 1.0 >>> av = sum(alpha**n.days * iq ... for n, iq in map(lambda (day, iq), today=max(days): (today-day, iq), ... sorted(zip(days, IQ), key=lambda p: p[0], reverse=True))) 95.0 The above is not pretty, so let's refactor it a bit: from collections import namedtuple from operator import itemgetter def smooth(iq_data, alpha=1, today=None): """Perform exponential smoothing with factor `alpha`. Time period is a day. Each time period the value of `iq` drops `alpha` times. The most recent data is the most valuable one. &quo

Css Subclass Of Class Code Example

Example: css last child with class /*This will only work if the last child of someEID has the class .myclassName if the last child does not have class name us js*/ #someEID .myClassName :last-child { background : blue ; }

Angular Material - How To Add A Tooltip To A Disabled Button

Answer : This doesn't work because it is triggered by mouseenter event which doesn't get fired by most browsers for disabled elements. A workaround is to add matTooltip to a parent element: <div matTooltip="You cannot delete that" [matTooltipDisabled]="!isButtonDisabled()"> <button mat-raised-button [disabled]="isButtonDisabled()"> <mat-icon>delete</mat-icon> </button> </div> The example above assumes that there is a method for determining if the button should be enabled or not. By using matTooltipDisabled the tooltip will be shown only if the button is disabled. References: https://github.com/angular/material2/issues/5040 https://github.com/angular/material2/issues/7953 I had a similar issue while displaying tooltip on a disabled icon button. The given solution was not practical for me, because adding an additional div on top of the button, messed up the layout of the button rel