Posts

Showing posts from April, 2006

Conda Install Specific Version Of A Package Code Example

Example 1: conda install package #To install a package in currently active enviroment conda install package-name Example 2: conda import specific version conda install < pkg > = < version > #for example conda install matplotlib=1.4.3

Can I Put Anything Inside DL/DT/DDs?

Answer : Updated answer based on comments: This was originally answered in 2011 for HTML 4, but the answer is different for HTML5: dt Flow content, but with no header, footer, sectioning content, or heading content descendants. dd Flow content. dt element reference on W3C dd element reference on W3C Original answer: DT elements should contain inline content. DD elements should contain block-level content. Definition lists vary only slightly from other types of lists in that list items consist of two parts: a term and a description. The term is given by the DT element and is restricted to inline content. The description is given with a DD element that contains block-level content. Source: W3C This question is also an interesting read: Why use definition lists (DL,DD,DT) tags for HTML forms instead of tables? Inside a DL you can only put DT and DD tags. A DT tag is an inline tag, so you should not put block elements in it. A DD tag can contain basically anyt

How To Add Icon Button In Flutter Code Example

Example: flutter change the icon of icon button on pressed bool selected = true ; //... Widget build ( BuildContext context ) { return Scaffold ( body : Center ( child : IconButton ( icon : Icon ( selected ? Icons . celebration : Icons . title ) , onPressed : ( ) { setState ( ( ) { selected = ! selected ; } ) ; } , ) , //IconButton ) , //Center ) ; //Scaffold }

Css :last-child Example

The :last-child CSS pseudo-class represents the last element among a group of sibling elements. /* Selects any <p> that is the last element among its siblings */ p:last-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 :last-child Examples Basic example HTML < div > < p > This text isn't selected. </ p > < p > This text is selected! </ p > </ div > < div > < p > This text isn't selected. </ p > < h2 > This text isn't selected: it's not a `p`. </ h2 > </ div > CSS p:last-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 > < li

Responsive Iframe Bootstrap Code Example

Example 1: embed-responsive-item <div class= "embed-responsive embed-responsive-16by9" > <iframe class= "embed-responsive-item" src= "https://www.youtube.com/embed/zpOULjyy-n8?rel=0" allowfullscreen></iframe> </div> Example 2: video bootstrap <!-- 21 : 9 aspect ratio --> <div class= "embed-responsive embed-responsive-21by9" > <iframe class= "embed-responsive-item" src= "..." ></iframe> </div> <!-- 16 : 9 aspect ratio --> <div class= "embed-responsive embed-responsive-16by9" > <iframe class= "embed-responsive-item" src= "..." ></iframe> </div> <!-- 4 : 3 aspect ratio --> <div class= "embed-responsive embed-responsive-4by3" > <iframe class= "embed-responsive-item" src= "..." ></iframe> </div> <!-- 1 : 1 aspect ratio --> <div clas

Forloop In React Code Example

Example: react for loop < tbody > { [ .. . Array ( 10 ) ] . map ( ( x , i ) => < ObjectRow key = { i } / > ) } < / tbody >

Difference Between Relative And Absolute Positioning In Html Code Example

Example: position relative and absolute difference in css <div class=”parent”> <div class=”box” id=”one”>One</div> <div class=”box” id=”two”>Two</div> <div class=”box” id=”three”>Three</div> <div class=”box” id=”four”>Four</div></div>

How To Justify Text To Left In Html Code Example

Example 1: html text justify <p style= "text-align: justify;" > Justify to width </p> Example 2: how to justify text in html <p align= "justify" >

Creating And Update Laravel Eloquent

Answer : Here's a full example of what "lu cip" was talking about: $user = User::firstOrNew(array('name' => Input::get('name'))); $user->foo = Input::get('foo'); $user->save(); Below is the updated link of the docs which is on the latest version of Laravel Docs here: Updated link Updated: Aug 27 2014 - [ updateOrCreate Built into core...] Just in case people are still coming across this... I found out a few weeks after writing this, that this is in fact part of Laravel's Eloquent's core... Digging into Eloquent’s equivalent method(s). You can see here: https://github.com/laravel/framework/blob/4.2/src/Illuminate/Database/Eloquent/Model.php#L553 on :570 and :553 /** * Create or update a record matching the attributes, and fill it with values. * * @param array $attributes * @param array $values * @return static */ public static function updateOrCreate(array $attributes, array $values = ar

Double Color Background Css Code Example

Example: double color background css background : linear-gradient ( <angle> , color1 color1-stop-at , color2 color2-start-at ) ;

Js Removeclass Code Example

Example 1: javascript remoev css class //remove a css class from an element document. getElementById ( "myElementID" ) .classList. remove ( "class_name" ) ; Example 2: how to remove a class from element with javascript const div = document. querySelector ( 'div' ) // Get element from DOM div.classList. remove ( 'info' ) // Remove class "info" Example 3: jquery remove class //Remove this same line after copying Basic Syntax : $ ( element ) . removeClass ( "myClass yourClass" ) ------------------------------------------------------------------------------------- Html code example : <p class= "red highlight" >test1</p> <p class= "red highlight marked" >test2</p> <p class= "red highlight" >test3</p> <p class= "red highlight" >test4</p> // remove all highlight class from p tag <script> $ ( "p" ) . removeClass ( "hi

Can Jconsole Data Be Retrieved From The Command Line?

Answer : jconsole just provides a wrapper around the JMX MBeans that are in the platform MBeanServer . You can write a program to connect to your VM using the Attach API which would then query the MBeans. Or you can expose the platform MBeanServer over RMI and query the MBeans that way. See the java.lang.management package for more info Maybe jvmtop is worth a look. It's a command-line tool which provides a live-view for several metrics. Example output of the VM overview mode: JvmTop 0.4.1 amd64 8 cpus, Linux 2.6.32-27, load avg 0.12 http://code.google.com/p/jvmtop PID MAIN-CLASS HPCUR HPMAX NHCUR NHMAX CPU GC VM USERNAME #T DL 3370 rapperSimpleApp 165m 455m 109m 176m 0.12% 0.00% S6U37 web 21 11272 ver.resin.Resin [ERROR: Could not attach to VM] 27338 WatchdogManager 11m 28m 23m 130m 0.00% 0.00% S6U37 web 31 19187 m.jvmtop.JvmTop 20m 3544m 13m 130m 0.93% 0.47% S6U37 web 20 16733 artup.Bootstrap 159m

Adding Http Headers To Window.location.href In Angular App

Answer : When you use $window.location.href the browser is making the HTTP request and not your JavaScript code. Therefore, you cannot add a custom header like Authorization with your token value. You could add a cookie via JavaScript and put your auth token there. The cookies will automatically be sent from the browser. However, you will want to review the security implications of using a cookie vs. a header. Since both are accessible via JavaScript, there is no additional attack vector there. Unless you remove the cookie after the new page loads, there may be a CSRF exploit available. This answer is NOT a safe way, as the token is exposed in the URL, which is logged in browser history, access logs, etc. Use a domain cookie instead. I'll leave the answer as it can be an easy way to debug in your local setup. I am using JWT as authentication on a Laravel PHP backend, and it works by putting ?token=... in the URL. For example, when using AngularJS with satellizer plug

Gameobject Unity Setactive Code Example

Example 1: setactive unity gameObject . SetActive ( true ) ; gameObject . SetActive ( false ) ; Example 2: doing void when gameobject setactive unity void OnEnable ( ) //This void works only when the script is enabled, but when the GameObject enables, the script does to so you can use for gameObject activating { Debug . Log ( "PrintOnEnable: script was enabled" ) ; //Your code here } void OnDisable ( ) //Same for the Disable function { Debug . Log ( "PrintOnDisable: script was disabled" ) ; //Your code here }

A Href Tel Css Code Example

Example: html telephone < a href = " tel:0612345678 " > Call me! </ a >

Millis() Arduino What Is Code Example

Example 1: arduino millis() /*Description Returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Syntax */ time = millis ( ) ; Example 2: arduino millis /*Description Returns the number of milliseconds passed since the Arduino board began running the current program. This number will overflow (go back to zero), after approximately 50 days. Syntax */ time = millis ( ) /* Returns Number of milliseconds passed since the program started. Return Data type: unsigned long. */

Cpp Cout Variable Code Example

Example 1: cout value c++ # include <iostream> using namespace std ; int main ( ) { int a , b ; char str [ ] = "Hello Programmers" ; /* Single insertion operator */ cout << "Enter 2 numbers - " ; cin >> a >> b ; cout << str ; cout << endl ; /* Multiple insertion operator */ cout << "Value of a is " << a << endl << "Value of b is " << b ; return 0 ; } Example 2: how to cout in c++ std :: cout << "Hello World!" << std :: endl ; //Or you can do std :: cout << "Hello World!" << ; //Only in some scenarios

Csgo Furiousss Settings Code Example

Example: furioussss crosshair viewmodel_fov 68; viewmodel_offset_x 2.5; viewmodel_offset_y 0; viewmodel_offset_z -1.5; viewmodel_presetpos 3; cl_viewmodel_shift_left_amt 1.5; cl_viewmodel_shift_right_amt 0.75; viewmodel_recoil 0; cl_righthand 1;

Android Center Text On Canvas

Image
Answer : Try the following: Paint textPaint = new Paint(); textPaint.setTextAlign(Paint.Align.CENTER); int xPos = (canvas.getWidth() / 2); int yPos = (int) ((canvas.getHeight() / 2) - ((textPaint.descent() + textPaint.ascent()) / 2)) ; //((textPaint.descent() + textPaint.ascent()) / 2) is the distance from the baseline to the center. canvas.drawText("Hello", xPos, yPos, textPaint); Center with Paint.getTextBounds() : private Rect r = new Rect(); private void drawCenter(Canvas canvas, Paint paint, String text) { canvas.getClipBounds(r); int cHeight = r.height(); int cWidth = r.width(); paint.setTextAlign(Paint.Align.LEFT); paint.getTextBounds(text, 0, text.length(), r); float x = cWidth / 2f - r.width() / 2f - r.left; float y = cHeight / 2f + r.height() / 2f - r.bottom; canvas.drawText(text, x, y, paint); } Paint.Align.CENTER doesn't mean that the reference point of the text is vertically centered. The reference point

Hr Mdn Css Code Example

Example: hr css mdn /* Answer to: "hr css mdn" */ /* The HTML <hr> element represents a thematic break between paragraph-level elements: for example, a change of scene in a story, or a shift of topic within a section. Here's the documentation to this <hr> (Horizontal Rule) tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/hr */

4chan A Code Example

Example 1: 4chan Tumblr is worst and i dont even use either. Example 2: 4chan Remember, this website is the dark hairy asshole of the internet. But sometimes cool stuff happens here.

Android Beginner Difference Between Padding And Margin

Image
Answer : Margin Margins make up the vertical and horizontal areas between elements. If elements have no margins around them, they will bump right up against each other. In other words, he space outside of, or between, elements is what comprises the margin areas. Padding The padding of an element is the horizontal and vertical space that’s set around the content area of the targeted element. So padding is on the inside of a box, not the outside. Padding is for inside/within components. Eg. TextView , Button , EditText etc. Eg. space between the Text and Border Margin is to be applied for the on-outside of the components. Eg. space between left edge of the screen and border of your component Visual representation is great in : Difference between a View's Padding and Margin With Padding , i have seen a difference in 2.2, 2.3 and say 4.3, 4.4 in such cases: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns

Button Css Generator 2020 Code Example

Example: css button generator <!-- The <button> tag produces a button. Place the text/media you want to be on the button by placing it between the opening and closing tags : --> <button>Click me!</button> <!-- It is possible to add attributes , such as 'id' and 'type' , into the opening tag , just like most other elements : --> <button id= "submitButton" type= "submit" >Click here to submit!</button>

Building Dockerfile Fails When Touching A File After A Mkdir

Image
Answer : Looking at https://registry.hub.docker.com/u/library/jenkins/, it seems that /var/jenkins_home is a volume. You can only create files there while the container is running, presumably with a volume mapping like docker run ... -v /your/jenkins/home:/var/jenkins_home ... The docker build process knows nothing about shared volumes. This is currently investigated in docker/docker/issues/3639, and summarized in this comment: Okay, I did little research and it seems that volume is non-mutable between Dockerfile instruction . Here even smaller Dockerfile for testing: FROM busybox RUN mkdir /tmp/volume RUN echo "hello" > /tmp/volume/hello VOLUME ["/tmp/volume/"] RUN [[ -f /tmp/volume/hello ]] RUN rm /tmp/volume/hello RUN [[ ! -e /tmp/volume/hello ]] On each instruction we create new volume and copy content from original volume . Update April 2019: Use DOCKER_BUILDKIT=1 The new builder does not exhibit this behavior. Example

Creating A Javascript Alert With Php That Has A Php Variable Inside?

Answer : You only forgot quotations that are required for the JavaScript alert. If you passed 'hello' to the function, your current code would create alert as: alert(hello) instead of doing: alert("hello") Therefore, change your line to the following (two double quotes are added before and after concatenating $error): echo '<script type="text/javascript">alert("'.$error.'");</script>'; and you can use your function: died('error on whatever'); Display variable php in alert javascript <?php function died($error) { ?> <script>alert("<?php echo $error; ?>")</script> <?php die(); } ?>

Programiz C Code Example

Example: basic cpp programs // Your First C++ Program # include <iostream> int main ( ) { std :: cout << "Hello World!" ; return 0 ; }

Css Text-align-last Example

The text-align-last CSS property sets how the last line of a block or a line, right before a forced line break, is aligned. Syntax /* Keyword values */ text-align-last : auto ; text-align-last : start ; text-align-last : end ; text-align-last : left ; text-align-last : right ; text-align-last : center ; text-align-last : justify ; /* Global values */ text-align-last : inherit ; text-align-last : initial ; text-align-last : unset ; Values auto The affected line is aligned per the value of text-align , unless text-align is justify , in which case the effect is the same as setting text-align-last to start . start The same as left if direction is left-to-right and right if direction is right-to-left. end The same as right if direction is left-to-right and left if direction is right-to-left. left The inline contents are aligned to the left edge of the line box. right The inline contents are aligned to the right edge of the line box. center The inline conten

Can I Run Mac OS X As A Hyper-V Virtual Machine?

Answer : No. Hyper-V is very specific about supported OS's and the generic drivers are very Microsoft specific.