Posts

Showing posts from November, 2019

Converting HTML To Plain Text In PHP For E-mail

Answer : Use html2text (example HTML to text), licensed under the Eclipse Public License. It uses PHP's DOM methods to load from HTML, and then iterates over the resulting DOM to extract plain text. Usage: // when installed using the Composer package $text = Html2Text\Html2Text::convert($html); // usage when installed using html2text.php require('html2text.php'); $text = convert_html_to_text($html); Although incomplete, it is open source and contributions are welcome. Issues with other conversion scripts: Since html2text (GPL) is not EPL-compatible. lkessler's link (attribution) is incompatible with most open source licenses. here is another solution: $cleaner_input = strip_tags($text); For other variations of sanitization functions, see: https://github.com/ttodua/useful-php-scripts/blob/master/filter-php-variable-sanitize.php Converting from HTML to text using a DOMDocument is a viable solution. Consider HTML2Text, which requires PHP5: http://www.howtocreate.co.uk/p

Could Not Find Com.android.tools.build:gradle:5.6

Answer : Don't confuse gradle with the Android Gradle plugin. classpath 'com.android.tools.build:gradle:5.6' It is the Android Gradle plugin and 5.6 doesn't exist . Use the latest stable release: classpath 'com.android.tools.build:gradle:3.5.0' Check the release notes for other versions. To change the gradle version, edit the file gradle/wrapper/gradle-wrapper.properties distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip More info in official doc. There is currently no version 5.6 for the Gradle plugin version. The link below lists all the latest releases for the Gradle plugin versions on Google's Marvel repository. https://mvnrepository.com/artifact/com.android.tools.build/gradle?repo=google I think what you mean is the distributionUrl version in your Gradle wrapper properties: Go to your gradle-wrapper.properties file and complete as required: distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GR

164 Cm In Inches Code Example

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

Adb Logcat Specific App Code Example

Example: android logs for app on terminal adb logcat | grep -F "`adb shell ps | grep com.asanayoga.asanarebel | tr -s [:space:] ' ' | cut -d' ' -f2`"

Array Initializer List Java Code Example

Example: java array initialization int [ ] data = { 10 , 20 , 30 , 40 , 50 , 60 , 71 , 80 , 90 , 91 } ; // or int [ ] data ; data = new int [ ] { 10 , 20 , 30 , 40 , 50 , 60 , 71 , 80 , 90 , 91 } ;

Sass And Scss Tutorial Code Example

Example 1: css sass scss /*SMART DIFFERENCE*/ /*CSS*/ body { font : 100 % Helvetica , sans-serif ; color : #333 ; } /*SCSS*/ $ font-stack : Helvetica , sans-serif ; $ primary-color : #333 ; body { font : 100 % $font-stack ; color : $primary-color ; } /*SASS*/ $ font-stack : Helvetica , sans-serif $ primary-color : #333 body font : 100 % $font-stack color : $primary-color Example 2: Sass Tutorial /* Define standard variables and values for website */ $ bgcolor : lightblue ; $ textcolor : darkblue ; $ fontsize : 18 px ; /* Use the variables */ body { background-color : $bgcolor ; color : $textcolor ; font-size : $fontsize ; }

Angular Material: Mat-select Not Selecting Default

Answer : Use a binding for the value in your template. value="{{ option.id }}" should be [value]="option.id" And in your selected value use ngModel instead of value . <mat-select [(value)]="selected2"> should be <mat-select [(ngModel)]="selected2"> Complete code: <div> <mat-select [(ngModel)]="selected2"> <mat-option *ngFor="let option of options2" [value]="option.id">{{ option.name }}</mat-option> </mat-select> </div> On a side note as of version 2.0.0-beta.12 the material select now accepts a mat-form-field element as the parent element so it is consistent with the other material input controls. Replace the div element with mat-form-field element after you upgrade. <mat-form-field> <mat-select [(ngModel)]="selected2"> <mat-option *ngFor="let option of options2" [value]="option.id"

Boxes Placement In Tcolorbox

Image
Answer : Obviously, you would use the \tcbox macro version for your boxes, rather than the environment form. Calculation of the stackgap is shown automated in this MWE. (Note: this example works starting with V2.30 of tcolorbox). \documentclass{article} \usepackage{stackengine} \usepackage{tcolorbox} \begin{document} \def\boxone{\tcbox[nobeforeafter]{This is a test}} \def\boxtwo{\tcbox[nobeforeafter]{Another test}} \def\boxthree{\tcbox[nobeforeafter,minipage,width=0.7in]{this is a very long box}} \stackon[\heightof{\boxthree}-\heightof{\boxone}-\heightof{\boxtwo}]% {\boxtwo}{\boxone}~\boxthree \end{document} Taking a similar tack to Steven Segletes's answer but using the xcoffins package, which allows us to pick points on the various boxes to line up: \documentclass{article} \usepackage{tcolorbox} \usepackage{xcoffins} \NewCoffin{\CoffinA} \NewCoffin{\CoffinB} \NewCoffin{\CoffinC} \begin{document} % Set up content in three coffins \SetHorizontalCoffin{\CoffinA}

Android: API Level VS. Android Version

Image
Answer : Well, API is for development, so the changes in new API version are more "inside". But new version of Android usually adds more features for users, that are "visible". Check this page http://developer.android.com/guide/appendix/api-levels.html, there is a table that shows relations between versions and API levels. Multiple versions of Android can have the same API level but the API as an integer allows developers to more easily target devices. The chart below will give you an idea of their relationship but only the documentation contains exhaustive listings of the API levels and how they differ from each other. Source: developer.android.com. Because this data is gathered from the new Google Play Store app, which supports Android 2.2 and above, devices running older versions are not included. However, in August, 2013, versions older than Android 2.2 accounted for about 1% of devices that checked in to Google servers (not those that actually vi

Pip Install Clear Cache Code Example

Example 1: ignore cache pip # Add --no-cache-dir before install pip --no-cache-dir install scipy Example 2: clear pip cache # this doesnt clear it but allows install with no cache pip install PACKAGE --no-cache-dir Example 3: pip clear download cache pip cache dir

Bottom Border On Bootstrap Row

Answer : You could do this with a pseudo element with left and right margin to overcome the padding issue: @import "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"; .row-bordered:after { content: ""; display: block; border-bottom: 1px solid #ccc; margin: 0 15px; } <div class="container"> <div class="row row-bordered"> <div class="col-xs-10"> Heading Text </div> <div class="col-xs-2 text-right"> <a href="#"><span class="glyphicon glyphicon-pencil"></span></a> <a href="#"><span class="glyphicon glyphicon-trash"></span></a> </div> </div> </div> The solution above longer works in Bootstrap 4 due to switching to Flexbox, but a few modifications fixes it: .row-bordered { position: relative; } .row-bordered:after

Brew Install Node And Npm Code Example

Example 1: brew install npm brew install node Example 2: install node brew brew update # As a safe measure you should run brew doctor to make sure your system is ready to brew . Run the command below and follow any recommendations from brew doctor . brew doctor # Next , add Homebrew’s location to your $ PATH in your . bash_profile or . zshrc file . echo 'export PATH="/usr/local/opt/icu4c/sbin:$PATH"' >> ~ / . profile echo 'export PATH="/usr/local/opt/icu4c/bin:$PATH"' >> ~ / . profile # Next , install Node ( npm will be installed with Node ) : brew install node node - v Example 3: install nodejs via homebrew $ / usr / bin / ruby - e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Coding Language To Make Unity Code Example

Example: what language does unity use C# : most used by far Boo : obscure language that looks Python UnityScript : version of JavaScript , but not identical to

Print Name In C Code Example

Example 1: print variable c printf ( "%d\n" , x ) ; Example 2: print name of file argv c int main ( int argc , char * argv [ ] ) { int i ; for ( i = 0 ; i < argc ; ++ i ) { printf ( "%s\n" , argv [ i ] ) ; } }

C# Invoke Unity Code Example

Example: unity invoke void Start ( ) { Invoke ( /*In quotes is the function name*/ "TurnLastPOff" , /*Time to wait*/ 2 ) ; } public void StartWithDelay ( ) { print ( "This should be printed after 2 seconds" ) ; }

Amazon Linux AMI Vs Ubuntu

Answer : Amazon Linux AMI is a red hat based distro so things like the package installer or the tools for service manage are different, and another thing you need to consider is the way of bootstraping, amazon instances are more flexible to do some things in cloudformation in the ubuntu way the best form to do it is with cloudinit https://help.ubuntu.com/community/CloudInit, you need to consider the packages too are multiple packages that not are native supported by Amazon Linux.

Fps Counter Unity Code Example

Example: unity fps counter using System . Collections ; using System . Collections . Generic ; using UnityEngine ; using UnityEngine . UI ; using UnityEngine . SceneManagement ; public class FpsScript : MonoBehaviour { [ SerializeField ] private Text fpsText ; [ SerializeField ] private float hudRefreshRate = 1f ; private float timer ; private void Update ( ) { if ( Time . unscaledTime > timer ) { int fps = ( int ) ( 1f / Time . unscaledDeltaTime ) ; fpsText . text = fps + " FPS on " + SceneManager . GetActiveScene ( ) . path ; timer = Time . unscaledTime + hudRefreshRate ; } } }

Conditional Display Of Html Element Forms

Answer : What worked: You had two buttons, both visible in the beginning. And on click of one button, you hid a div , and made another visible. Now you need a situation when the divs should be hidden in the beginning, and then show when you click a button. By default, for all elements where a explicit visibility attribute is not given, visibility is considered to be visible . To make the button invisible, you need to add visibility:hidden to the button. You can do it two ways: In the code for the div s, make then "invisible by default" by adding style='visibility:hidden' . Add another javascript function that is called on load of the page, and makes both the divs invisible: function hideBoth() { document.getElementById("cont1").style.visibility="hidden"; document.getElementById("cont2").style.visibility="hidden"; } Call it on load of your page: <body onload='hideBoth()'> This line: document.get

Can't Install Kali Linux From USB, Fails To Find CD-ROM Drive

Answer : You could resolve the error by repeating the steps : Run the installer. Open a shell ( ALT + F2 ). Create the directory cdrom directly on the root of the file system: mkdir /cdrom Note : If you got problems making the directory /cdrom, disable the CD-rom player in BIOS or disconnect the cable Mount the USB as if it is a CD-ROM: mount -t vfat /dev/sdb1 /cdrom Where sdb1 is your USB device. You could carry on installation now After executing mount -t vfat /dev/sdb1 /cdrom , cd into the /cdrom directory and do an ls to see if the files are there. Then press ALT - F1 to go back, continue and re-select "detect CDROM" Source :ubuntu and debian Another layman solution was : when the Window shows CDROM couldn't be mounted , Unplug your USB from system and re insert it wait for mount/ detection (usb LED glow) Hit Continue You could do what I did. Hit escape, type install, hit enter, skip CD drive. If you

Convert Byte To Int Python Code Example

Example: python bytes to int """ Python 3 """ # int.from_bytes( bytes, byteorder, *, signed=False ) # bytes must evaluate as bytes-like object # byteorder is optional. someString must evaluate as 'big' xor 'little' # signed is optional. someBoolean opmust evaluate as boolean # examples: someBytes = b'\x00\x01\x00\x02\x00\x03' someInteger = int . from_bytes ( someBytes ) someInteger = int . from_bytes ( someBytes , 'big' ) someInteger = int . from_bytes ( someBytes , byteorder = 'little' , signed = True ) """ Python 2.7 """ # no bytes is str in Python 2.7 import struct struct . unpack ( pattern , someBytes ) # someBytes is of type str or byte array # pattern is a string begining with '>' or '<', # followed by as many 'H' or 'B' chars needed # to cover the someBytes' length. # '>' stands for Big-endian # '<' stand

Completely Uninstall PostgreSQL 9.0.4 From Mac OSX Lion?

Image
Answer : The following is the un-installation for PostgreSQL 9.1 installed using the EnterpriseDB installer. You most probably have to replace folder /9.1/ with your version number. If /Library/Postgresql/ doesn't exist then you probably installed PostgreSQL with a different method like homebrew or Postgres.app . To remove the EnterpriseDB One-Click install of PostgreSQL 9.1: Open a terminal window. Terminal is found in: Applications->Utilities->Terminal Run the uninstaller: sudo /Library/PostgreSQL/9.1/uninstall-postgresql.app/Contents/MacOS/installbuilder.sh If you installed with the Postgres Installer, you can do: open /Library/PostgreSQL/9.2/uninstall-postgresql.app It will ask for the administrator password and run the uninstaller. Remove the PostgreSQL and data folders. The Wizard will notify you that these were not removed. sudo rm -rf /Library/PostgreSQL Remove the ini file: sudo rm /etc/postgres-reg.ini Remove the PostgreSQL user using System Preferences -> U

Can I Replace A Steward In Hearthfire?

Answer : The Dismiss Steward mod allows you to dismiss stewards. I admit I haven't tried it yet but if you really want Lydia fired, I recommend making a save, downloading the mod, and giving it a try. Just make sure that you have a save from before you installed the mod just in case something catastrophic happens. There is but one way and its to slay her, she cant go back to breezehome because her home has been changed to your other house, if you kill her, you can recruit new stewards in after her, but if there is a way to return her there, i dont know of it.