Posts

Showing posts from November, 2020

Adding Asterisk To Required Fields In Bootstrap 3

Answer : Use .form-group.required without the space. .form-group.required .control-label:after { content:"*"; color:red; } Edit: For the checkbox you can use the pseudo class :not(). You add the required * after each label unless it is a checkbox .form-group.required:not(.checkbox) .control-label:after, .form-group.required .text:after { /* change .text in whatever class of the text after the checkbox has */ content:"*"; color:red; } Note: not tested You should use the .text class or target it otherwise probably, try this html: <div class="form-group required"> <label class="col-md-2 control-label">&#160;</label> <div class="col-md-4"> <div class="checkbox"> <label class='text'> <!-- use this class --> <input class="" id="id_tos" name="tos" required="required" type="

CakePHP Find Condition For A Query Between Two Dates

Answer : $conditions = array( 'conditions' => array( 'and' => array( array('Item.date_start <= ' => $date, 'Item.date_end >= ' => $date ), 'Item.title LIKE' => "%$title%", 'Item.status_id =' => '1' ))); Try the above code and ask if it not worked for you. Edit: As per @Aryan request, if we have to find users registered between 1 month: $start_date = '2013-05-26'; //should be in YYYY-MM-DD format $this->User->find('all', array('conditions' => array('User.reg_date BETWEEN '.$start_date.' AND DATE_ADD('.$start_date.', INTERVAL 30 DAY)'))); Here is CakePHP BETWEEN query example. I'm defining my arrays as variables, and then using those variables in my CakePHP find function call: // just return

Inline Css Background Color Code Example

Example 1: how to write css in html <p style= "color: blue; font-size: 46px;" > Example 2: html style tag <html > <head > <style > h1 { color : red ; } p { color : blue ; } </style> </head> <body> <h1>A heading</h1> <p>A paragraph.</p> </body> Example 3: how to add css to html <link rel= "stylesheet" href= "hi.css" >

Css :first-of-type Example

The :first-of-type CSS pseudo-class represents the first element of its type among a group of sibling elements. /* Selects any <p> that is the first element of its type among its siblings */ p:first-of-type { color : red ; } Note : As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. Syntax :first-of-type Examples Styling the first paragraph HTML < h2 > Heading </ h2 > < p > Paragraph 1 </ p > < p > Paragraph 2 </ p > CSS p:first-of-type { color : red ; font-style : italic ; } Result Nested elements This example shows how nested elements can also be targeted. Note that the universal selector ( * ) is implied when no simple selector is written. HTML < article > < div > This `div` is first! </ div > < div > This < span > nested `span` is first </ span > ! </ div > < div > This < em >

Aggregate Mongodb Example

Example 1: how to write the aggragation in mongodb > db . mycol . aggregate ( [ { $group : { _id : "$by_user" , num_tutorial : { $ sum : 1 } } } ] ) { "_id" : "tutorials point" , "num_tutorial" : 2 } { "_id" : "Neo4j" , "num_tutorial" : 1 } > Example 2: MONGODB AGGREGATION tutorials db . stocks . aggregate ( [ { $match : { "price" : 2000 } } ] ) Example 3: MONGODB AGGREGATION tutorials db . stocks . insertMany ( [ { name : "Infosys" , qty : 100 , price : 800 } , { name : "TCS" , qty : 100 , price : 2000 } , { name : "Wipro" , qty : 2500 , price : 300 } ] ) Example 4: MONGODB AGGREGATION tutorials db . stocks . find ( ) . pretty ( )

Create Json Objects In Python Code Example

Example: python json string to object import json x = '{ "name":"John", "age":30, "city":"New York"}' y = json . loads ( x ) print ( y [ "age" ] )

Can I Unlock The Crystal Cruiser With Type C Of The Rock Cruiser?

Answer : I can confirm that the Rock Cruiser Type C can bypass the first two steps of this quest chain, finally having done it in game. You must find the beacon event in the Rock Homeworlds sector without the aid of a quest marker, but the event can still be generated irrelevant of the stasis pod quests, and your beginning crystal crew member will give you the blue choice option once the event is found. Long-ranged scanners help a lot with this, as the event should only be present at a beacon with no ship detected, as well as no store, no distress call, and no hazard. Once you enter the hidden sector, you do get a quest marker for the crystal ship location, which is quite nice. I guess I should have read the updated wiki page that I linked in my question before posting. Alternatively, the Rock Cruiser type C in the Advanced Edition starts with a single Crystal aboard the ship, allowing you to skip the first two events normally required in order to allow access to the blue opti

Adding Dictionaries Together, Python

Answer : If you're interested in creating a new dict without using intermediary storage: (this is faster, and in my opinion, cleaner than using dict.items()) dic2 = dict(dic0, **dic1) Or if you're happy to use one of the existing dicts: dic0.update(dic1) Here are quite a few ways to add dictionaries. You can use Python3's dictionary unpacking feature. ndic = {**dic0, **dic1} Or create a new dict by adding both items. ndic = dict(dic0.items() + dic1.items()) If your ok to modify dic0 dic0.update(dic1) If your NOT ok to modify dic0 ndic = dic0.copy() ndic.update(dic1) If all the keys in one dict are ensured to be strings ( dic1 in this case, of course args can be swapped) ndic = dict(dic0, **dic1) In some cases it may be handy to use dict comprehensions (Python 2.7 or newer), Especially if you want to filter out or transform some keys/values at the same time. ndic = {k: v for d in (dic0, dic1) for k, v in d.items()} >>> dic0 = {&#

Mousepointer Css Code Example

Example 1: cursor pointer .class { cursor : pointer ; } Example 2: cursor not pointer #Element { cursor : pointer ; /*When you point on this element, cursor will be a pointer.*/ } #Element { cursor : default ; /*Will make the cursor not point.*/ } Example 3: pointer help ptr++ ; // Pointer moves to the next int position ( as if it was an array ) ++ptr ; // Pointer moves to the next int position ( as if it was an array ) ++*ptr ; // The value of ptr is incremented ++ ( *ptr ) ; // The value of ptr is incremented ++* ( ptr ) ; // The value of ptr is incremented *ptr++ ; // Pointer moves to the next int position ( as if it was an array ) . But returns the old content ( *ptr ) ++ ; // The value of ptr is incremented * ( ptr ) ++ ; // Pointer moves to the next int position ( as if it was an array ) . But returns the old content *++ptr ; // Pointer moves to the next int position , and then get's accessed , with your code , segfault * ( ++ptr )

AddID In JQuery?

Answer : ID is an attribute, you can set it with the attr function: $(element).attr('id', 'newID'); I'm not sure what you mean about adding IDs since an element can only have one identifier and this identifier must be unique. do you mean a method? $('div.foo').attr('id', 'foo123'); Just be careful that you don't set multiple elements to the same ID. Like this : var id = $('div.foo').attr('id'); $('div.foo').attr('id', id + ' id_adding'); get actual ID put actuel ID and add the new one

Cook With Comali Promo Code Example

Example: cook with comali promo var person={ first_name:"johnny", last_name: "johnson", phone:"703-3424-1111" }; for (var property in person) { console.log(property,":",person[property]); }

Cross-compile A Rust Application From Linux To Windows

Answer : Other answers, while technically correct, are more difficult than they need to be. There's no need to use rustc (in fact it's discouraged, just use cargo ), you only need rustup , cargo and your distribution's mingw-w64. Add the target (you can also change this for whatever target you're cross compiling for): rustup target add x86_64-pc-windows-gnu rustup toolchain install stable-x86_64-pc-windows-gnu You can build your crate easily with: cargo build --target x86_64-pc-windows-gnu No need for messing around with ~/.cargo/config or anything else. EDIT: Just wanted to add that while you can use the above it can also sometimes be a headache. I wanted to add that the rust tools team also maintains a project called cross: https://github.com/rust-embedded/cross This might be another solution that you want to look into The Rust distribution only provides compiled libraries for the host system. However, according to Arch Linux's wiki page on Rust, you could c

Adding Git Credentials On Windows

Answer : Ideally, you should enter: git config --global credential.helper manager-core Then your password would be stored in the Windows Credential Manager. See more at "Unable to change git account". On the first push, a popup will appear asking for your credentials (username/password) for the target server (for instance github.com ) If not, that might means your credentials were already stored. If they are incorrect, a simple git credential-manager reject https://github.com will remove them (on Windows, again. On Mac: git credential-osxkeychain erase https://github.com ) With Git 2.29 (Q4 2020), the parser in the receiving end of the credential protocol is loosen to allow credential helper to terminate lines with CRLF line ending, as well as LF line ending. See commit 356c473 (03 Oct 2020) by Nikita Leonov ( nyckyta ). (Merged by Junio C Hamano -- gitster -- in commit 542b3c2, 05 Oct 2020) credential : treat CR/LF as line endings in the credential protocol

Tag Button Bootstrap 4 Code Example

Example 1: bootstrap buttons Sizes Fancy larger or smaller buttons? Add .btn-lg or .btn-sm for additional sizes. <button type= "button" class= "btn btn-primary btn-lg" >Large button</button> <button type= "button" class= "btn btn-secondary btn-lg" >Large button</button> <button type= "button" class= "btn btn-primary btn-sm" >Small button</button> <button type= "button" class= "btn btn-secondary btn-sm" >Small button</button> <button type= "button" class= "btn btn-primary btn-lg btn-block" >Block level button</button> <button type= "button" class= "btn btn-secondary btn-lg btn-block" >Block level button</button> <a href= "#" class= "btn btn-primary btn-lg active" role= "button" aria-pressed= "true" >Primary link</a> <a href= "#

16cm In Inches Code Example

Example: cm to inches const cm = 1 ; console . log ( `cm : $ { cm } = in : $ { cmToIn ( cm ) } ` ) ; function cmToIn ( cm ) { var in = cm / 2.54 ; return in ; }

Can PHP CURL Retrieve Response Headers AND Body In A Single Request?

Answer : One solution to this was posted in the PHP documentation comments: http://www.php.net/manual/en/function.curl-exec.php#80442 Code example: $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 1); // ... $response = curl_exec($ch); // Then, after your curl_exec call: $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header = substr($response, 0, $header_size); $body = substr($response, $header_size); Warning: As noted in the comments below, this may not be reliable when used with proxy servers or when handling certain types of redirects. @Geoffrey's answer may handle these more reliably. Many of the other solutions offered this thread are not doing this correctly. Splitting on \r\n\r\n is not reliable when CURLOPT_FOLLOWLOCATION is on or when the server responds with a 100 code. Not all servers are standards compliant and transmit just a \n for new lines. Detecting the size of the headers via CURLINFO_HEA

Mongo Restart Ubuntu Code Example

Example 1: how to restart mongodb server in ubuntu sudo systemctl restart mongodb # it will restarts running mongodb server Example 2: mongodb restart command ubuntu sudo systemctl restart mongod Example 3: start mongodb service ubuntu sudo systemctl start mongod sudo systemctl stop mongod Example 4: ubuntu start mongodb sudo mongod -- fork -- config / etc / mongod . conf

Transparent Blur Background Css Code Example

Example 1: how to blur background color in css background : rgba ( 255 , 255 , 255 , 0.5 ) ; backdrop-filter : blur ( 5 px ) ; Example 2: how to do a background blur in css /* Answer to "blur behind element css" */ /* This blurs everything behind the element it's applied to */ backdrop-filter : blur ( 10 px ) ; Example 3: css blur background /* Keyword value */ backdrop-filter : none ; /* URL to SVG filter */ backdrop-filter : url ( commonfilters.svg#filter ) ; /* <filter-function> values */ backdrop-filter : blur ( 2 px ) ; backdrop-filter : brightness ( 60 % ) ; backdrop-filter : contrast ( 40 % ) ; backdrop-filter : drop-shadow ( 4 px 4 px 10 px blue ) ; backdrop-filter : grayscale ( 30 % ) ; backdrop-filter : hue-rotate ( 120 deg ) ; backdrop-filter : invert ( 70 % ) ; backdrop-filter : opacity ( 20 % ) ; backdrop-filter : sepia ( 90 % ) ; backdrop-filter : saturate ( 80 % ) ; /* Multiple filters */ backdrop-filter : url ( filters.svg#filt

Css :first-child Example

The :first-child CSS pseudo-class represents the first element among a group of sibling elements. /* Selects any <p> that is the first element among its siblings */ p:first-child { color : lime ; } Note : As originally defined, the selected element had to have a parent. Beginning with Selectors Level 4, this is no longer required. Syntax :first-child Examples Basic example HTML < div > < p > This text is selected! </ p > < p > This text isn't selected. </ p > </ div > < div > < h2 > This text isn't selected: it's not a `p`. </ h2 > < p > This text isn't selected. </ p > </ div > CSS p:first-child { color : lime ; background-color : black ; padding : 5px ; } Result Styling a list HTML < ul > < li > Item 1 </ li > < li > Item 2 </ li > < li > Item 3 < ul > < li > Item 3.1 </ li > &

22 Inches In Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

String Javascript Mdn Code Example

Example 1: javascript string lentrh var myString = "string test" ; var stringLength = myString . length ; console . log ( stringLength ) ; // Will return 11 because myString // is 11 characters long... Example 2: javascript string starts with //checks if a string starts with a word function startsWith ( str , word ) { return str . lastIndexOf ( word , 0 ) == = 0 ; } startsWith ( "Welcome to earth." , "Welcome" ) ; //true Example 3: mdn js string String ( thing )