Posts

Showing posts from February, 2013

Angular *ngfor Index Code Example

Example 1: ngfor index < ul > < li *ngFor = " let item of items; let i = index " [attr.data-index] = " i " > {{item}} </ li > </ ul > Example 2: ngfor get index < ul > < li *ngFor = " let item of items; let i = index " [attr.data-index] = " i " > {{item}} </ li > </ ul > Example 3: ngfor index /* ngFor with index in angular is used here for generating 'li' element till the studentDetails array length. And also make a note if you are using angular 1 then you have to replace 'let' with '#', but its ok if you are using angular 2 or above. */ < ul > < li *ngFor = " let student of studentDetails; index as i; " [attr.data-index] = " i " > {{student}} </ li > </ ul > /* I hope it will help you. Namaste */

Css Text Outline Black Code Example

Example 1: css text outline /* You have 2 options The first is experimental */ /* text-stroke */ #example { font-size : 1 em ; -webkit-text-stroke : 1 px #000000 ; } /* Use 4 shadows Probably best to use this until the above is standardised */ #example { font-size : 1 em ; text-shadow : -1 px -1 px 0 #000 , 1 px -1 px 0 #000 , -1 px 1 px 0 #000 , 1 px 1 px 0 #000 ; } Example 2: text border css h1 { -webkit-text-stroke : 1 px black ; }

Android Retrofit 2 + RxJava: Listen To Endless Stream

Answer : Here my solution: You can use the @Streaming annotation: public interface ITwitterAPI { @GET("/2/rsvps") @Streaming Observable<ResponseBody> twitterStream(); } ITwitterAPI api = new Retrofit.Builder() .baseUrl("http://stream.meetup.com") .addCallAdapterFactory(RxJavaCallAdapterFactory.create()) .build().create(ITwitterAPI.class); With @Streaming we can get raw input From ResponseBody . Here my function to wrap body divided by lines with events: public static Observable<String> events(BufferedSource source) { return Observable.create(new Observable.OnSubscribe<String>() { @Override public void call(Subscriber<? super String> subscriber) { try { while (!source.exhausted()) { subscriber.onNext(source.readUtf8Line()); } subscriber.onCompleted(); } catch (IOException e)

10000000 2 Log 1000000 Code Example

Example: log(10000000/1000) Example for finding IDF -Inverse Document Frequency

Enum Unity Code Example

Example 1: unity enum using UnityEngine ; using System . Collections ; public class EnumScript : MonoBehaviour { enum Direction { North , East , South , West } ; void Start ( ) { Direction myDirection ; myDirection = Direction . North ; } Direction ReverseDirection ( Direction dir ) { if ( dir == Direction . North ) dir = Direction . South ; else if ( dir == Direction . South ) dir = Direction . North ; else if ( dir == Direction . East ) dir = Direction . West ; else if ( dir == Direction . West ) dir = Direction . East ; return dir ; } } Example 2: unity enum private enum State { Idle , Walk , Attack , }

Adb Command Not Found

Answer : In my case with Android Studio 1.1.0 path was this /Users/wzbozon/Library/Android/sdk/platform-tools Add the following to ~/.bash_profile export PATH=~/Library/Android/sdk/tools:$PATH export PATH=~/Library/Android/sdk/platform-tools:$PATH Is adb installed? To check, run the following command in Terminal: ~/Library/Android/sdk/platform-tools/adb If that prints output, skip these following install steps and go straight to the final Terminal command I list: Launch Android Studio Launch SDK Manager via Tools -> Android -> SDK Manager Check Android SDK Platform-Tools Run the following command on your Mac and restart your Terminal session: echo export "PATH=~/Library/Android/sdk/platform-tools:$PATH" >> ~/.bash_profile Note: If you've switched to zsh, the above command should use .zshenv rather than .bash_profile Make sure adb is in your user's $PATH variable. or You can try to locate it with whereis and run it wit

Converting HTML To PDF Using IText

Image
Answer : Why your code doesn't work As explained in the introduction of the HTML to PDF tutorial, HTMLWorker has been deprecated many years ago. It wasn't intended to convert complete HTML pages. It doesn't know that an HTML page has a <head> and a <body> section; it just parses all the content. It was meant to parse small HTML snippets, and you could define styles using the StyleSheet class; real CSS wasn't supported. Then came XML Worker. XML Worker was meant as a generic framework to parse XML. As a proof of concept, we decided to write some XHTML to PDF functionality, but we didn't support all of the HTML tags. For instance: forms weren't supported at all, and it was very hard to support CSS that is used to position content. Forms in HTML are very different from forms in PDF. There was also a mismatch between the iText architecture and the architecture of HTML + CSS. Gradually, we extended XML Worker, mostly based on requests from customer

Bootstrap Text Size Code Example

Example 1: bootstrap 4 font bold font-weight-bold Example 2: bootstrap text size < p class = " h1 " > h1. Bootstrap heading </ p > < p class = " h2 " > h2. Bootstrap heading </ p > < p class = " h3 " > h3. Bootstrap heading </ p > < p class = " h4 " > h4. Bootstrap heading </ p > < p class = " h5 " > h5. Bootstrap heading </ p > < p class = " h6 " > h6. Bootstrap heading </ p > Example 3: bootstrap blockquote < blockquote class = " blockquote " > < p class = " mb-0 " > Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante. </ p > < footer class = " blockquote-footer " > Someone famous in < cite title = " Source Title " > Source Title </ cite > </ footer > </ blockquote > Example 4: bootstrap 4 responsive para

Conditional Formatting Based On Another Cell's Value

Image
Answer : Note: when it says "B5" in the explanation below, it actually means "B{current_row}", so for C5 it's B5, for C6 it's B6 and so on. Unless you specify B B B 5 - then you refer to one specific cell. This is supported in Google Sheets as of 2015: https://support.google.com/drive/answer/78413#formulas In your case, you will need to set conditional formatting on B5. Use the " Custom formula is " option and set it to =B5>0.8*C5 . set the " Range " option to B5 . set the desired color You can repeat this process to add more colors for the background or text or a color scale. Even better, make a single rule apply to all rows by using ranges in " Range ". Example assuming the first row is a header: On B2 conditional formatting, set the " Custom formula is " to =B2>0.8*C2 . set the " Range " option to B2:B . set the desired color Will be like the previous example but works on all rows, not just row 5

Add Onclick Event To SVG Element

Answer : It appears that all of the JavaScript must be included inside of the SVG for it to run. I was unable to reference any external function, or libraries. This meant that your code was breaking at svgstyle = svgobj.getStyle(); This will do what you are attempting. <?xml version="1.0" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg xmlns='http://www.w3.org/2000/svg' version='1.1' height='600' width='820'> <script type="text/ecmascript"><![CDATA[ function changerect(evt) { var svgobj=evt.target; svgobj.style.opacity= 0.3; svgobj.setAttribute ('x', 300); } ]]> </script> <rect onclick='changerect(evt)' style='fill:blue;opacity:1' x='10' y='30' width='100'height='100' /> </sv

ADB Android Device Unauthorized

Answer : It's likely that the device is no longer authorized on ADB for whatever reason. 1. Check if authorized: <ANDROID_SDK_HOME>\platform-tools>adb devices List of devices attached 4df798d76f98cf6d unauthorized 2. Revoke USB Debugging on phone If the device is shown as unauthorized , go to the developer options on the phone and click "Revoke USB debugging authorization" (tested with JellyBean & Samsung GalaxyIII). 3. Restart ADB Server: Then restarted adb server adb kill-server adb start-server 4. Reconnect the device The device will ask if you are agree to connect the computer id. You need to confirm it. 5. Now Check the device It is now authorized! adb devices <ANDROID_SDK_HOME>\platform-tools>adb devices List of devices attached 4df798d76f98cf6d device Ohhh finally I figured it out! After removing Eclipse directory I installed it into another directory. echo %ANDROID_SDK_HOME% has displayed wrong p

Skeleton Cdn.com Code Example

Example 1: skeleton cdn <link rel= "stylesheet" href= "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.css" integrity= "sha512-5fsy+3xG8N/1PV5MIJz9ZsWpkltijBI48gBzQ/Z2eVATePGHOkMIn+xTDHIfTZFVb9GMpflF2wOWItqxAP2oLQ==" crossorigin= "anonymous" /> Example 2: skeleton library cdn /*Skeleton 2.0.4*/ https : //cdnjs.cloudflare.com/ajax/libs/skeleton/ 2.0 .4 /skeleton.min.css https : //cdnjs.cloudflare.com/ajax/libs/skeleton/ 2.0 .4 /skeleton.css

Could Not Get Lock /var/lib/dpkg/lock-frontend - Open (11: Resource Temporarily Unavailable) E: Unable To Acquire The Dpkg Frontend Lock (/var/lib/dpkg/lock-frontend), Is Another Process Using It? Code Example

Example 1: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) Method 1 ps aux | grep -i apt sudo kill -9 < process_id > Method 2 sudo lsof /var/lib/dpkg/lock sudo lsof /var/lib/apt/lists/lock sudo lsof /var/cache/apt/archives/lock sudo kill -9 < process_id > sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock sudo dpkg --configure -a sudo apt update Example 2: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? ps aux | grep -i dpkg // Kill processes which are running sudo kill -9 < pid > // Restart the accounts daemon sudo systemctl restart accounts-daemon Example 3: E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it? ps aux | grep -i apt sudo kill <