Posts

Showing posts from August, 2012

Can I Override !important?

Image
Answer : Ans is YES !important can be overridden but you can not override !important by a normal declaration. It has to be higher specificity than all other declarations. However it can be overridden with a higher specificity !important declaration. This code snippet in Firefox's parser will explain how it works: if (HasImportantBit(aPropID)) { // When parsing a declaration block, an !important declaration // is not overwritten by an ordinary declaration of the same // property later in the block. However, CSSOM manipulations // come through here too, and in that case we do want to // overwrite the property. if (!aOverrideImportant) { aFromBlock.ClearLonghandProperty(aPropID); return PR_FALSE; } changed = PR_TRUE; ClearImportantBit(aPropID); } Good read Specifics on CSS Specificity CSS Specificity: Things You Should Know Here's an example to show how to override CSS HTML <div id="hola" class="hola"&

Stod C++ Example

Example: how to convert a string to a double c++ double new = std :: stod ( string ) ;

Html Code Element Code Example

Example 1: what is the code element in html The HTML < code > element displays its contents styled in a fashion intended to indicate that the text is a short fragment of computer code . By default , the content text is displayed using the user agent ' s default monospace font Example 2: html tag The < code > tag is used to define a piece of computer code . The content inside is displayed in the browser ' s default monospace font . Example 3: what is element in html HTML Elements are what make up HTML in general < p > is an element

Bootstrap Row With Columns Of Different Height

Image
Answer : This is a popular Bootstrap question, so I've updated and expanded the answer for Bootstrap 3 and Bootstrap 4... The Bootstrap 3 "height problem" occurs because the columns use float:left . When a column is “floated” it’s taken out of the normal flow of the document. It is shifted to the left or right until it touches the edge of its containing box. So, when you have uneven column heights , the correct behavior is to stack them to the closest side. Note : The options below are applicable for column wrapping scenarios where there are more than 12 col units in a single .row . For readers that don't understand why there would ever be more than 12 cols in a row , or think the solution is to "use separate rows" should read this first There are a few ways to fix this.. (updated for 2018) 1 - The 'clearfix' approach (recommended by Bootstrap) like this (requires iteration every X columns). This will force a wrap every X number

Can We Decrypt Sha256 Hash Code Example

Example: can we decrypt sha256 SHA256 is a hashing function, not an encryption function. Secondly, since SHA256 is not an encryption function, it cannot be decrypted. ... In that case, SHA256 cannot be reversed because it's a one-way function.

Call To Undefined Function Imagecreatefromjpeg() And GD Enabled

Image
Answer : I think you've installed an incomplete version of gd . When you compile the gd extension, use the flag --with-jpeg-dir=DIR and --with-freetype-dir=DIR ps. dont forget make clean picture below is the incomplete version of gd: picture below is the complete version of gd: In my case, GD was missing after upgrading to PHP 7.3. So, I just added it by using the following command : sudo apt-get install php7.3-gd

Best Wordpress Free Templates Plugin Code Example

Example: download free plugins and themes wordpress Genesis for WP - Free Download WordPress Themes and Plugins https://www.genesisforwp.com/

Can Std::transform Be Replaced By Std::accumulate?

Answer : Those two algorithms have completely different purpose. std::accumulate is known as fold in functional programming world, and it's purpose is iterate over elements of a sequence and apply two-argument folding operation to those elements, with one argument being result of previous fold and other being element of the sequence. It naturally returns the a single result - a fold of all elements of a sequence into one value. On the other hand, std::transform copies values from one sequence to another, applying a unary operation to each element. It returns an iterator to the end of sequence. The fact that you can supply any code as the fold operation allows us to use std::accumulate as a generic loop replacement, including an option to copy values into some other container, but that it is ill-advised, as the whole reason for introducing those (rather simple) algorithms was to make programs more explicit. Making one algo to perform the task which is normally associat

Angular 9: I18n In TypeScript

Answer : Check this blog https://blog.ninja-squad.com/2019/12/10/angular-localize/ @Component({ template: '{{ title }}' }) export class HomeComponent { title = $localize`You have 10 users`; } And You have to manually add it to your messages.fr.xlf <trans-unit id="6480943972743237078"> <source>You have 10 users</source> <target>Vous avez 10 utilisateurs</target> </trans-unit> don't forgot re serve your angular application. UPDATE FOR ID @Component({ template: '{{ title }}' }) export class HomeComponent { title = $localize`:@@6480943972743237078:`; } https://github.com/angular/angular/blob/252966bcca91ea4deb0e52f1f1d0d3f103f84ccd/packages/localize/init/index.ts#L31 The better way of translationId is: title = $localize`:@@Home.Title:Some title text` and you have to manually add it to your messages.xx.xlf (for example messages.fr.xlf and so on) <trans-unit id="Home.Title"

AngularJS $on Event Handler Trigger Order

Answer : Very good question. Event handlers are executed in order of initialization. I haven't really thought about this before, because my handlers never needed to know which one run first, but by the look of you fiddle I can see that the handlers are called in the same order in which they are initialized. In you fiddle you have a controller controllerA which depends on two services, ServiceA and ServiceB : myModule .controller('ControllerA', [ '$scope', '$rootScope', 'ServiceA', 'ServiceB', function($scope, $rootScope, ServiceA, ServiceB) {...} ] ); Both services and the controller define an event listener. Now, all dependencies need to be resolved before being injected, which means that both services will be initialized before being injected into the controller. Thus, handlers defined in the services will be called first, because service factories are initialized before contro

Css Selector Sibling Before Code Example

Example 1: css select all siblings after element /*To match to any sibling element after the selector on the left, use the tilde symbol '~'. This is called the general sibling combinator. */ h1 ~ p { color : black ; } Example 2: 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 3: 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> &

Angular2 Multiple Constructor Implementations Are Not Allowed TS2392

Answer : Making multiple constructors with the same parameters doesn't make sense unless they have different types, in Typescript you can do the following: class Foo { questions: any[]; constructor(service: QuestionSignupStepOneService, param2?: Param2Type) { this.questions = service.getQuestions(); if(param2){ console.log(param2); } } } This is equal to two constructors, the first one is new Foo(service) and the second one is new Foo(service, param2) . Use ? to state that the parameter is optional. If you want two constructors with the same parameter but for different types you can use this: class Foo { questions: any[]; constructor(service: QuestionSignupStepOneService | QuestionSignupStepOneAService) { if(service instanceof QuestionSignupStepOneService){ this.questions = service.getQuestions(); } else { this.questions = service.getDifferentQuestions(); } } }

Longest Increasing Subsequence Leetcode Code Example

Example 1: longest common subsequence class Solution : def longestCommonSubsequence ( self , text1 : str , text2 : str ) -> int : "" " text1 : horizontally text2 : vertically "" " dp = [ [ 0 for _ in range ( len ( text1 ) + 1 ) ] for _ in range ( len ( text2 ) + 1 ) ] for row in range ( 1 , len ( text2 ) + 1 ) : for col in range ( 1 , len ( text1 ) + 1 ) : if text2 [ row - 1 ] == text1 [ col - 1 ] : dp [ row ] [ col ] = 1 + dp [ row - 1 ] [ col - 1 ] else : dp [ row ] [ col ] = max ( dp [ row - 1 ] [ col ] , dp [ row ] [ col - 1 ] ) return dp [ len ( text2 ) ] [ len ( text1 ) ] Example 2: longest increasing subsequence when elements hae duplicates # include <iostream> # include <algorithm> using namespace std ; // define maximum possible leng

Alternative Segmentation Techniques Other Than Watershed For Soil Particles In Images

Image
Answer : You could try using Connected Components with Stats already implemented as cv2.connectedComponentsWithStats to perform component labeling. Using your binary image as input, here's the false-color image: The centroid of each object can be found in centroid parameter and other information such as area can be found in the status variable returned from cv2.connectedComponentsWithStats . Here's the image labeled with the area of each polygon. You could filter using a minimum threshold area to only keep larger polygons Code import cv2 import numpy as np # Load image, Gaussian blur, grayscale, Otsu's threshold image = cv2.imread('2.jpg') blur = cv2.GaussianBlur(image, (3,3), 0) gray = cv2.cvtColor(blur, cv2.COLOR_BGR2GRAY) thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)[1] # Perform connected component labeling n_labels, labels, stats, centroids = cv2.connectedComponentsWithStats(thresh, connectivity=4) # Create fal