Posts

Showing posts from January, 2015

Bootstrap How To Make A Image Responsive Code Example

Example: how to make image responsive bootstrap 4 <img src= "..." class= "img-fluid" alt= "Responsive image" >

A TypeScript GUID Class?

Answer : There is an implementation in my TypeScript utilities based on JavaScript GUID generators. Here is the code: class Guid { static newGuid() { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8); return v.toString(16); }); } } // Example of a bunch of GUIDs for (var i = 0; i < 100; i++) { var id = Guid.newGuid(); console.log(id); } Please note the following: C# GUIDs are guaranteed to be unique. This solution is very likely to be unique. There is a huge gap between "very likely" and "guaranteed" and you don't want to fall through this gap. JavaScript-generated GUIDs are great to use as a temporary key that you use while waiting for a server to respond, but I wouldn't necessarily trust them as the primary key in a database. If you are going to rely on a JavaScript-generated GUID, I wo

3. Write A Java Program To Calculate The Average Value Of Array Elements. Code Example

Example: find average of numbers in array java public class JavaExample { public static void main ( String [ ] args ) { double [ ] arr = { 19 , 12.89 , 16.5 , 200 , 13.7 } ; double total = 0 ; for ( int i = 0 ; i < arr . length ; i ++ ) { total = total + arr [ i ] ; } /* arr.length returns the number of elements * present in the array */ double average = total / arr . length ; /* This is used for displaying the formatted output * if you give %.4f then the output would have 4 digits * after decimal point. */ System . out . format ( "The average is: %.3f" , average ) ; } }

Can We Use More Colors In Batch Script?

Image
Answer : Can I use more the 16 colours in a Windows batch file? No, as most most Windows apps only support 16 colours. However, in the Windows 10 Insiders Build #14931 the Windows Console was updated to support 24-bit RGB true color. Unfortunately as mentioned above most Windows apps cannot make use of this enhancement (yet). However, using Windows Subsystem for Linux (WSL), Linux scripts and tools can use the Console's new 24-bit color support: One of the most frequent requests we receive is to increase the number of colors that the Windows Console can support. We love nothing more than to deliver features you ask for! But rather than just add a few more colors, or limit our console to a mere 256 colors, in Windows 10 Insiders Build #14931, we’ve updated the Windows Console to support full, glorious 24-bit RGB true color! This is actually a little tricky to demo since most Windows apps only support 16 colors at most whereas the Linux world has broadly supported 256 col

Calculating A 2D Vector's Cross Product

Answer : Implementation 1 returns the magnitude of the vector that would result from a regular 3D cross product of the input vectors, taking their Z values implicitly as 0 (i.e. treating the 2D space as a plane in the 3D space). The 3D cross product will be perpendicular to that plane, and thus have 0 X & Y components (thus the scalar returned is the Z value of the 3D cross product vector). Note that the magnitude of the vector resulting from 3D cross product is also equal to the area of the parallelogram between the two vectors, which gives Implementation 1 another purpose. In addition, this area is signed and can be used to determine whether rotating from V1 to V2 moves in an counter clockwise or clockwise direction. It should also be noted that implementation 1 is the determinant of the 2x2 matrix built from these two vectors. Implementation 2 returns a vector perpendicular to the input vector still in the same 2D plane. Not a cross product in the classical sense but c

`1234567890-=qwertyuioooooooooooooooooooop[]asdfghjkl;'#\zxcvbnm,./QWERTYUIOPASDFGHJKLZXCVBNM|?:@~}{+_)(*&^%$£"!1234567890 Code Example

Example 1: `1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>? You definitely indeed have a QWERTY keyboard. Example 2: `1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./ quit this tab/google search! go watch YOUTUBE! I feel so sorry for your boredom curse!

Adding Printer In Windows 7 X32 Causes 0x000006be Error

Answer : You likely have driver corruption issue. You can try to remove all printer driver and reinstall them. A similar thread exists over technet: http://social.technet.microsoft.com/Forums/en/itprovistaprinting/thread/3e47b7b6-00a3-47e1-9e28-e615fbff5f87 but that particular thread is for windows vista so the answer may or may not work. Since it worked, here's the text from the linked document (Originally by Arthur Xie, a Microsoft Employee): Remove a printer Click the "Start" button, type PRINTER in the search box and press Enter. Find the icons of installed printers, and delete them. Right-click on the blank part of the window, and choose "Run as administrator"->"Server Properties". On the Drivers tab, select the listed printers and click the Remove button. Please then select Remove driver and driver package. Open Start menu, input APPWIZ.CPL in the Search box and press ENTER to launch "Programs and Features". Try to rem

Can't Change Custom Class Of UIButton To GIDSignInButton

Image
Answer : You should try assign GIDSignInButton not to the Button Object from the Object library but to the the View Object instead It's work for me. It will look like this using UIView instead of UIButton. That's because GIDSignInButton is a subclass of UIView, not UIButton. Add to the storyboard / nib a regular UIView and change it's class to GIDSignInButton instead. From google doc: Add a GIDSignInButton to your storyboard, XIB file, or instantiate it programmatically. To add the button to your storyboard or XIB file, add a View and set its custom class to GIDSignInButton. You can create UIButton and then on its action method you can write this code for signing via google: GIDSignIn.sharedInstance().signIn() It works for me, in this way you can customize UIButton according to your requirement and also perform signin by using google

Console Print In Php Code Example

Example 1: php console log // Assuming you are wishing to log to the JS Console... < ? php function consoleLog ( $msg ) { echo ' < script type = "text/javascript" > ' . 'console . log ( ' . $msg . ' ) ; < / script > ' ; } consoleLog ( 'Hello , console ! ' ) ; ? > Example 2: php console log // A little correction / improvement to @Kaotik's answer: < ? php function consoleLog ( $msg ) { echo ' < script type = "text/javascript" > console . log ( ' . str_replace ( '<' , '\\x3C' , json_encode ( $msg ) ) . ' ) ; < / script > ' ; } consoleLog ( 'Hello , console ! ' ) ; ? > Example 3: console php //display message in console < ? php function console_log ( $msg ) { echo ' < script > ' . 'console . log ( "'.$msg .' " ) < / script > ' ;

Entity Framework Dbcontext Best Practices Code Example

Example: generic dbcontext entity framework core public class SampleContext : GuidDbContext { public IDbSet < Foo > Foos { get ; set ; } public IDbSet < Bar > Bars { get ; set ; } }

11:59 Pm PST In Kuwait Time Code Example

Example: 9 pst to south africa time add 10 hours

String Escape Character C Code Example

Example: c escape characters Escape HEX in ASCII Character represented \a 07 Alert ( Beep , Bell ) ( added in C89 ) \b 08 Backspace \e 1 B Escape character \f 0 C Formfeed Page Break \n 0 A Newline ( Line Feed ) ; see notes below \r 0 D Carriage Return \t 09 Horizontal Tab \v 0 B Vertical Tab \\ 5 C Backslash \' 27 Apostrophe or single quotation mark \" 22 Double quotation mark \ ? 3F Question mark ( used to avoid trigraphs ) \nnn any The byte whose numerical value is given by nnn interpreted as an octal number \xhh… any The byte whose numerical value is given by hh… interpreted as a hexadecimal number \uhhhh none Unicode code point below 10000 hexadecimal \Uhhhhhhhh none Unicode code point where h is a hexadecimal digit

Converting From EPS To SVG Format

Answer : Currently what's working best for me on linux is the following: epstopdf foo.eps pdf2svg foo.pdf foo.svg I believe the first command is a wrapper for ghostscript, and the second is a wrapper for calls to the Poppler and Cairo libraries. On ubuntu, they're in the packages texlive-font-utils and pdf2svg. Gradients come out looking right, but don't seem to be editable in inkscape. I tried using inkscape and uniconverter for this purpose, and as of Jan 2013, both seemed broken when tested on an example containing nothig but some very simple line art. Inkscape throws errors and can't open the eps file. Uniconverter crashes. Scribus and sk1 may work, but seem awkward and not really suited for this task. Uniconvertor is currently the most convenient option. It's a command-line tool that shares code with the sK1 Project. You won't have to bother cropping the image in sK1 if you use uniconvertor, so it's more automated. Run it like this: uniconvertor befo

Convert Int String Shorthand Javascript Code Example

Example: convert nuber into string react js var foo = 45 ; var bar = '' + foo ;

Convert From Int To String Arduino Code Example

Example: int to string arduino String stringOne = "Hello String"; // using a constant String String stringOne = String('a'); // converting a constant char into a String String stringTwo = String("This is a string"); // converting a constant string into a String object String stringOne = String(stringTwo + " with more"); // concatenating two strings String stringOne = String(13); // using a constant integer String stringOne = String(analogRead(0), DEC); // using an int and a base String stringOne = String(45, HEX); // using an int and a base (hexadecimal) String stringOne = String(255, BIN); // using an int and a base (binary) String stringOne = String(millis(), DEC); // using a long and a base String stringOne = String(5.698, 3); // using a float and the decimal places

How To Select Direct Child In Css Code Example

Example 1: direct child css selector > direct_child_element_seletor { rules ; } Example 2: css apply style to direct children /* Use the ">" selector to apply css to direct children of a parent element. example: https://jsfiddle.net/dbeachnau/54w6x0pj/2/ */ .parent > .child { color : red ; }

Angular 2 Get Current Route

Answer : Try this, import { Router } from '@angular/router'; export class MyComponent implements OnInit { constructor(private router:Router) { ... } ngOnInit() { let currentUrl = this.router.url; /// this will give you current url // your logic to know if its my home page. } } Try it import { Component } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; @Component({...}) export class MyComponent { constructor(private router:Router) { router.events.subscribe(event => { if (event instanceof NavigationEnd ) { console.log("current url",event.url); // event.url has current url // your code will goes here } }); } } Try any of these from the native window object. console.log('URL:' + window.location.href); console.log('Path:' + window.location.pathname); console.log('Host:' + window.location.host); console.log('Ho

How To Add Line Space Between Lines In Css Code Example

Example 1: line spacing css line-height : 20 px ; /* 4px +12px + 4px */ /* OR */ line-height : 1.7 em ; /* 1em = 12px in this case. 20/12 == 1.666666 */ Example 2: css line spacing line-height : 1.5 ; /* Prefered */ line-height : 1.5 em ; line-height : 150 % ; line-height : 24 px ;

9 Oz To Grams Code Example

Example: oz to g 1 ounce (oz) = 28.3495231 grams (g)

How To Make An Image Circle Css Code Example

Example 1: css photo circle img { clip-path : circle ( ) ; } Example 2: how to make an image circular html css img { border-radius : 50 % ; }