Posts

Showing posts from March, 2013

Cdnjs Jquery Code Example

Example 1: jquery cdn < script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" > < / script > Example 2: ajax cdn < script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" > < / script > Example 3: jqeury cdn //Note: This is for version 3.5.0. You can change it here \/ < script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js" integrity = "sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin = "anonymous" > < / script > Example 4: jquery cdn < script src = "https://code.jquery.com/jquery-3.5.1.min.js" > < / script > Example 5: jquery cdm < script src = "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js" > < / script > Example 6: jquery cdn < script src = "https://code.jquery.com/jquery-3.5.1.min.js" integrity = "sha256-9/ali

Can't Run Curl Command Inside My Docker Container

Answer : curl: command not found is a big hint, you have to install it with : apt-get update; apt-get install curl Ran into this same issue while using the CURL command inside my Dockerfile. As Gilles pointed out, we have to install curl first. These are the commands to be added in the 'Dockerfile'. FROM ubuntu:16.04 # Install prerequisites RUN apt-get update && apt-get install -y \ curl CMD /bin/bash So I added curl AFTER my docker container was running. (This was for debugging the container...I did not need a permanent addition) I ran my image docker run -d -p 8899:8080 my-image:latest (the above makes my "app" available on my machine on port 8899) (not important to this question) Then I listed and created terminal into the running container. docker ps docker exec -it my-container-id-here /bin/sh If the exec command above does not work, check this SOF article: Error: Cannot Start Container: stat /bin/sh: no such file or directory&quo

Std Map Find Key Code Example

Example: c++ map find // map::find # include <iostream> # include <map> int main ( ) { std :: map < char , int > mymap ; std :: map < char , int > :: iterator it ; mymap [ 'a' ] = 50 ; mymap [ 'b' ] = 100 ; mymap [ 'c' ] = 150 ; mymap [ 'd' ] = 200 ; it = mymap . find ( 'b' ) ; if ( it != mymap . end ( ) ) mymap . erase ( it ) ; // print content: std :: cout << "elements in mymap:" << '\n' ; std :: cout << "a => " << mymap . find ( 'a' ) -> second << '\n' ; std :: cout << "c => " << mymap . find ( 'c' ) -> second << '\n' ; std :: cout << "d => " << mymap . find ( 'd' ) -> second << '\n' ; return 0 ; }

C# - Capturing The Mouse Cursor Image

Image
Answer : While I can't explain exactly why this happens, I think I can show how to get around it. The ICONINFO struct contains two members, hbmMask and hbmColor, that contain the mask and color bitmaps, respectively, for the cursor (see the MSDN page for ICONINFO for the official documentation). When you call GetIconInfo() for the default cursor, the ICONINFO struct contains both valid mask and color bitmaps, as shown below (Note: the red border has been added to clearly show the image boundaries): Default Cursor Mask Bitmap Default Cursor Color Bitmap When Windows draws the default cursor, the mask bitmap is first applied with an AND raster operation, then the color bitmap is applied with an XOR raster operation. This results in an opaque cursor and a transparent background. When you call GetIconInfo() for the I-Beam cursor, though, the ICONINFO struct only contains a valid mask bitmap, and no color bitmap, as shown below (Note: again, the red border has been adde

Bootstrap 4 Card Examples

Example 1: card bootstrap 4 < div class = "card" style = "width:400px" > < img class = "card-img-top" src = "img_avatar1.png" alt = "Card image" style = "width:100%" > < div class = "card-body" > < h4 class = "card-title" > John Doe < / h4 > < p class = "card-text" > Some example text some example text . John Doe is an architect and engineer < / p > < a href = "#" class = "btn btn-primary" > See Profile < / a > < / div > < / div > Example 2: boostrap card < div class = "card" style = "width: 18rem;" > < div class = "card-body" > < h5 class = "card-title" > Card title < / h5 > < h6 class = "card-subtitle mb-2 text-muted" > Card subtitle < / h6 > < p class =

C# Split String Word Delimiter Code Example

Example 1: split using string c# //Split using a string delimiter instead of a char data . Split ( new string [ ] { "xx" } , StringSplitOptions . None ) ; Example 2: parse strings into words C# string text = "Hello World!" string [ ] textSplit = text . Split ( ) ;

Break Foreach Php Code Example

Example 1: php exit foreach $arr = array ( 'one' , 'two' , 'three' , 'four' , 'stop' , 'five' ) ; foreach ( $arr as $val ) { if ( $val == 'stop' ) { break ; /* You could also write 'break 1;' here. */ } echo "$val<br />\n" ; } /* Using the optional argument. */ $i = 0 ; while ( ++ $i ) { switch ( $i ) { case 5 : echo "At 5<br />\n" ; break 1 ; /* Exit only the switch. */ case 10 : echo "At 10; quitting<br />\n" ; break 2 ; /* Exit the switch and the while. */ default : break ; } } ? > Example 2: foreach loop in php < ? php $arr = [ 'Item 1' , 'Item 2' , 'Item 3' ] ; foreach ( $arr as $item ) { var_dump ( $item ) ; } $dict = array ( "key1" => "35&q

Card Flip Animation Between Activities

Image
Answer : From what I've got you can't do exactly that same card flip between activities. BUT, as you might already know you need overridePendingTransition() in order to animate transition between activities (doc here). Now all you need is an animation resource to do the trick. I used these: fade_in.xml <?xml version="1.0" encoding="utf-8"?><set xmlns:android="http://schemas.android.com/apk/res/android" > <scale android:duration="200" android:fromXScale="0.0" android:fromYScale="1.0" android:interpolator="@android:anim/accelerate_decelerate_interpolator" android:pivotX="50%" android:pivotY="50%" android:startOffset="200" android:toXScale="1.0" android:toYScale="1.0" /> <alpha android:duration="1" android:fromAlpha="0.0" android:startOffset="200" andr

42 Cm Into Inches Code Example

Example: cm to inch 1 cm = 0.3937 inch

Whatsapp Web Share Link Code Example

Example: whatsapp share link for website < a href = "https://api.whatsapp.com/send?text=www.google.com" data - action = "share/whatsapp/share" > Share via Whatsapp web < / a >

3 Color Gradient Image Generator Code Example

Example 1: css gradient generator /* 5 Best CSS Gradient Generator Links */ https : //cssgradient.io/ https : //www.colorzilla.com/gradient-editor/ https : //www.css-gradient.com/ https : //mycolor.space/gradient https : //uigradients.com/#Orca Example 2: Gradient Color Code Generator background-image : linear-gradient ( 90 deg , #020024 0 % , #090979 35 % , #00d4ff 100 % ) ;

An Array Of Zeros Matlab Code Example

Example 1: matlab matrix zeros X = zeros ( 4 ) % Creates a 4x4 matrix of zeros. X = zeros ( 3 , 2 ) % Creates a 3x2 matrix of zeros. Example 2: matlab zero vector row = zeros ( 1 , 10 ) ; column = zeros ( 10 , 1 ) ;

Arduino Nano Uploading Gives Error: Avrdude: Stk500_recv(): Programmer Is Not Responding

Answer : Know this is old but I ran onto it during my search for Nano(V3)'s not uploading so thought might help someone else. Problem is the bootloader - Arduino IDE BUT I Found an easy solution (right under my nose). I realized that my nano's had been uploading just fine then I had finally updated the Arduino AVR Boards from 1.6.20 to 1.6.21. I didn't think there was any problems because it still showed my Nano and ATmega328 etc in the board manager after the change. But the new boards manager has a new ATmega328 processor choice for the Nano. I changed processor: In the Arduino IDE select TOOLS > PROCESSOR > pulldown menu from ATmega328P to "ATmega328P (Old Bootloader)" . Since then, I have uploaded many programs to several different Nano's V3 (Prolofic interace Chipset) without issue. This error message basically shows up for any communication problem, so by itself, it is not all that instructive. The Arduino Nano is supposed to have au

Bootstrap Push Div Content To New Line

Answer : Do a row div. Like this: <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous"> <div class="grid"> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-12 bg-success">Under me should be a DIV</div> <div class="col-lg-6 col-md-6 col-sm-5 col-xs-12 bg-danger">Under me should be a DIV</div> </div> <div class="row"> <div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 bg-warning">I am the last DIV</div> </div> </div> If your your list is dynamically generated with unknown number and your target is to always have last div in a new line set last div class to "col-xl-12" and remove

Can Villagers Use Fence Gates?

Answer : No, villagers are not able to use fence gates. I tested this in creative, and they always used a long route with a door rather than a short route with a fence gate. I even blocked off the door and they just stood there. No . Villagers can only open and close wooden doors, but they cannot open and close fence gates. You can, of course, set up a fence gate, but the villagers may try to escape through that opening when you open the fence gate. A better way to trade with villagers is to set up a booth-like thing: F-Fence V=Villager FFF FFF FVFFFFVF FVVVVVVF FFFFFFFF This way, they cannot escape and you can still trade with them. No , they can't. They cannot use any mechanism without the help of redstone or stuff like pressure plates for wooden doors.

64 Inches In Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Change Chrome Omnibox To Use Google's NCR Link

Answer : It's not working because you haven't edited [google:baseURL] . Use this string https://www.google.com/search?q=%s EDIT: See comments Edit Sept 2015: This doesn't seem to work any more. There's a better way. If you edit the search string in the Preferences, you won't get autofill results. If you do it this way, you will. Change Chrome's Search Engine to Google.com: http://googlesystem.blogspot.ca/2013/07/change-chromes-search-engine-to.html Type google.com/ncr in the address bar and search for something Close Chrome Launch Chrome again, open a new tab and search for something using Chrome's omnibox. You should see an infobar that asks you: "would you like to search with google.com instead of [your local Google domain]?"

Angular-material: Input-group And Md-buttons On Same Line

Answer : Try the following code: <form layout layout-align="center" layout-padding> <div layout="row" flex> <md-input-container flex class="md-icon-float md-block md-title"> <label>Your font number</label> <!-- below is the material icons --> <md-icon class="material-icons">phone</md-icon> <input type="text"> </md-input-container> <div> <md-button class="md-raised"> <!-- below is the material icons --> <md-icon class="material-icons">search</md-icon> </md-button> </div> </div> </form> see a sample in the following link http://codepen.io/cmwang-cottageclothing/pen/BjpdVQ?editors=1000 Would like to provide a contemporary answer to this popular question. 1

Breadth First Search Time Complexity Analysis

Image
Answer : I hope this is helpful to anybody having trouble understanding computational time complexity for Breadth First Search a.k.a BFS. Queue graphTraversal.add(firstVertex); // This while loop will run V times, where V is total number of vertices in graph. while(graphTraversal.isEmpty == false) currentVertex = graphTraversal.getVertex(); // This while loop will run Eaj times, where Eaj is number of adjacent edges to current vertex. while(currentVertex.hasAdjacentVertices) graphTraversal.add(adjacentVertex); graphTraversal.remove(currentVertex); Time complexity is as follows: V * (O(1) + O(Eaj) + O(1)) V + V * Eaj + V 2V + E(total number of edges in graph) V + E I have tried to simplify the code and complexity computation but still if you have any questions let me know. Considering the following Graph we see how the time complexity is O(|V|+|E|) but not O(V*E). Adjacency List V E v0:{v1,v2} v1:{v3} v2:{v3} v3:{} Ope

Citing Mathematical Proofs Given On Math Stack Exchange

Answer : There are actually two questions on MathOverflow that ask how to cite answers found on MathOverflow. I would recommend following their advice. One of them is a fairly old question, whose answer is somewhat outdated. Summarizing: Even though you may not be legally obligated to show where you got your answer (for example, when MO points you to a theorem already in the literature), it is a good idea — it never hurts to be generous and honest. (And if you're copying part of an answer, not citing it would be plagiarism.) There is a little button for each answer that says "cite" and will give you a citation. You might have to reformat this to make it fit in your journal's bibliography style. Perhaps the person who posted it actually found it elsewhere and can provide a reference to you. Alternately, if you are willing to be publicly known here, you can find a way to exchange emails and hence give proper credit to the individual(s). In the past, I'

Asynchronous Shell Exec In PHP

Answer : If it "doesn't care about the output", couldn't the exec to the script be called with the & to background the process? EDIT - incorporating what @AdamTheHut commented to this post, you can add this to a call to exec : " > /dev/null 2>/dev/null &" That will redirect both stdio (first > ) and stderr ( 2> ) to /dev/null and run in the background. There are other ways to do the same thing, but this is the simplest to read. An alternative to the above double-redirect: " &> /dev/null &" I used at for this, as it is really starting an independent process. <?php `echo "the command"|at now`; ?> To all Windows users: I found a good way to run an asynchronous PHP script (actually it works with almost everything). It's based on popen() and pclose() commands. And works well both on Windows and Unix. function execInBackground($cmd) { if (substr(php_uname(), 0, 7) =

Amazon.Runtime.AmazonServiceException: Unable To Find Credentials

Answer : Create a credentials file at any path where you can access this path from web service application e.g. C:\awsfile\credentials but remember don't give any extension this file File should contains following data. [default] aws_access_key_id=[your_access_key] aws_secret_access_key=[your_secret_key] After this you need to set the path in appsetting tag in the Web.config file: <appSettings> <add key="AWSProfilesLocation" value="C:\awsfile\credentials" /> <add key="AWSRegion" value="us-east-1" /> </appSettings> In AWS Explorer for Visual Studio you can create user profiles that give you different permissions on AWS, then you can choose which profile you want to use in AWS Explorer. These profiles are available only to your Windows user account, if anyone else uses your computer then they will have to create their own profiles. Any software that you run under your user account can also use these profiles.

Check If CGRect Null In Getter

Answer : When you create an instance of your class, the _frame instance variable is automatically initialized, even before the init method is called. Since _frame is a C-struct ( CGRect ), its memory is cleared to all zeroes. This results in a CGRect with all zero values. CGRectNull is a special, non-zero CGRect . So your check using CGRectIsNull() will never be true. Using CGRectIsEmpty is a more proper check for this. Try - (CGRect)frame { if (CGRectIsEmpty(_frame)) _frame = CGRectMake(0,0,60,60); return _frame; } Here is an updated answer for Swift 4. You are able to simply use CGRect's isNull boolean property to check for CGRectNull now: let someRect = CGRect.null print(someRect.isNull) // true

Adding Window.event Handler To Typescript

Answer : This window.addEventListener('keydown', keyDownListener, false) window is defined will all events in lib.d.ts and this particular listener as addEventListener(type: "keydown", listener: (ev: KeyboardEvent) => any, useCapture?: boolean): void; or this, if you want to keep your original "style", window.onkeydown = (ev: KeyboardEvent): any => { //do something }

All Python Tkinter Fonts Code Example

Example 1: python tkinter font import tkinter from tkinter . font import Font root = tkinter . Tk ( ) font_1 = Font ( family = 'Arial' , size = 24 , weight = 'normal' , slant = 'italic' , underline = 1 , overstrike = 1 ) font_2 = Font ( family = 'Helvetica' , size = 12 , weight = 'bold' , slant = 'italic' , underline = 0 , overstrike = 0 ) font_3 = Font ( family = 'Courier' , size = 14 , weight = 'normal' , slant = 'roman' , underline = 0 , overstrike = 0 ) font_4 = Font ( family = 'Times' , size = 22 , weight = 'bold' , slant = 'roman' , underline = 0 , overstrike = 0 ) my_label = tkinter . Label ( master = root , text = 'Text' , font = font_1 ) my_label . pack ( ) tkinter . mainloop ( ) Exam

10 Minute Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds