Posts

Showing posts from July, 2003

Custom Add To Cart Button Woocommerce Ajax Code Example

Example: add_to_cart how to call it woocommerce add_action ( 'template_redirect' , 'quadlayers_add_to_cart_function' ) ; function quadlayers_add_to_cart_function ( ) { $product_id = 1326 ; if ( WC ( ) -> cart -> get_cart_contents_count ( ) == 0 ) { WC ( ) -> cart -> add_to_cart ( $product_id ) ; } }

Byte To String Conversion Java Code Example

Example 1: java convert bytes to string byte [ ] bytes = "hello" . getBytes ( ) ; String s = new String ( bytes , StandardCharsets . UTF_8 ) ; Example 2: byte to string One method is to create a string variable and then append the byte value to the string variable with the help of + operator . This will directly convert the byte value to a string and add it in the string variable . The simplest way to do so is using valueOf ( ) method of String class in java

Ansible Print Debug Msg Variable

Answer : Solution 1: Try this: - name: Print mosh version debug: "msg=Mosh Version: '{{ mosh_version.stdout }}'" More info in http://docs.ansible.com/YAMLSyntax.html#gotchas Edited: Something like this works perfect for me: - name: Check Ansible version command: ansible --version register: ansibleVersion - name: Print version debug: msg: "Ansible Version: {{ ansibleVersion.stdout }}" http://pastie.org/private/cgeqjucn3l5kxhkkyhtpta Solution 2: Simplest answer - debug: var=mosh_version.stdout Solution 3: I have displayed variable and message in the debug same task. Ansible Task - name: Report the /boot/initramfs file status for latest installed kernel debug: msg: "{{ ansible_hostname }} = {{INITRAMFS_LAST_KERNEL.stdout}}" Output TASK [os-upgrade.linux : Report the /boot/initramfs file status for latest installed kernel] ******************************************* ok: [ANSIBLENODE] => { "

Android Hide Keyboard Not Working - Cannot Hide Soft Keyboard

Answer : Changing HIDE_IMPLICIT_ONLY to 0 did it (after I changed to hideSoftInputFromWindow() from of hideSoftInputFromInputMethod() ). However I'm not sure why HIDE_IMPLICIT_ONLY isn't working since I am not explicitly opening the keyboard with a long press on Menu. Another option to prevent it from activity in AndroidManifest.xml file android:windowSoftInputMode="stateAlwaysHidden" - This method will prevent loading/showing keyboard when the activity is loaded. But when you click the editable component like edittext the keyboard will open. perfect for my requirement. <activity android:name=".Name" android:label="@string/app_name" android:windowSoftInputMode="stateAlwaysHidden"> 1.first bind your edit text token with keyboard and open i.e inputMethodManager.showSoftInput(_edittext, 0); //here _edittext is instance of view 2.keyboard will get hidden automatically if the edit

Change Font Size In Paragraph Latex Code Example

Example 1: latex text size \Huge \huge \LARGE \Large \large \normalsize \small \footnotesize \scriptsize \tiny Example 2: latex font sizes \Huge \huge \LARGE \Large \large \normalsize (default) \small \footnotesize \scriptsize \tiny

Check The Best Ratio Matching Fuzzywuzzy Python Code Example

Example 1: fuzzy lookup in python from fuzzywuzzy import process str2Match = "apple inc" strOptions = [ "Apple Inc." , "apple park" , "apple incorporated" , "iphone" ] Ratios = process . extract ( str2Match , strOptions ) print ( Ratios ) # You can also select the string with the highest matching percentage highest = process . extractOne ( str2Match , strOptions ) print ( highest ) Example 2: approximate string matching python #Installation pip install fuzzywuzzy #import from fuzzywuzzy import fuzz # Compare whole 2 strings fuzz . ratio ( "Catherine M Gitau" , "Catherine Gitau" ) #91 # Compares only untill the length of smallest string, # In below case strings that will be compared are, "Catherine M. Gi" & "Catherine Gitau" fuzz . partial_ratio ( "Catherine M. Gitau" , "Catherine Gitau" ) #100

Online C Compiler Code Example

Example 1: install c compiler windows Step 1 ) Go to http : //www.codeblocks.org/downloads and click Binary Release. Step 2 ) Choose the installer with GCC Compiler , e . g . , codeblocks - 17.12 mingw - setup . exe which includes MinGW's GNU GCC compiler and GNU GDB debugger with Code :: Blocks source files . Step 3 ) Run the downloaded installer and accept the default options . Step 4 ) Accept the Agreement Step 5 ) Keep the component selection default and click Next . Step 6 ) You may change the installation folder and click Next . Step 7 ) To launch Code :: Blocks double click on the icon . Step 8 ) It will detect the gcc compiler automatically , set it as default . Step 9 ) You will see the IDE Home screen . Example 2: online c compiler I Personally Like https : //www.programiz.com/c-programming/online-compiler/ Example 3: online c compiler You can try https : //www.onlinegdb.com/ this as well, works really well for me. You can also save code th

Latex Scale Figure To Textwidth Code Example

Example: latex image textwidth \ documentclass { article } \ usepackage { graphicx } \ begin { document } \ includegraphics [ width = 0.5 \ textwidth ] { file } \ end { document }

Coffin Dance Tabs Code Example

Example: coffin dance guitar tabs e|———————————————————————————— B|———————————3-3-3-3-1-1-1-1—— G|—3-3-3-3———————————————————— e|—1-1-1-1-3-3-3-3-3-3-3-3-3-3-3-3— e|—————————————————————————————————————————————6—5-6-5-6————— B|—1———————————————3—1————————————1——————————————————————————— G|————3-2—————0——0——————3——2-2-2—————3——2—0—0—————————————0–0— D|—————————3——————————————————————————– e|-6-5-6-5-6——————————————————————————————6—5-6-5-6———— B|————————————————3—1—————————1——————————————————————0–0— G|————————————0–0—————3-2-2-2————3-2-0-0—————————————————— e|-6-5-6-5-6——————————————————————————————6—5-6-5-6———— B|————————————————3—1—————————1——————————————————————0–0— G|————————————0–0—————3-2-2-2————3-2-0-0—————————————————— e|-6-5-6-5-6—————————————————————————— B|———————————————————3-3-3-3-1-1-1-1—————————- G|——————————3-3-3-3————————————————— e|—1-1-1-1-3-3-3-3————3-3-3-3-3-3 e|——3-3—————————————————————————————————————————— B|—————————1——————————————3—1——————————1—————

Apache Require All Granted Code Example

Example 1: #AllowOverride none #Require all denied Require all granted Example 2: #AllowOverride none #Require all denied Order allow,deny Allow from all

Add Internet Permission Android Flutter Code Example

Example: internet permission in flutter In the AndroidManifest.xml file located at android/app/src/main you need to add this permission inside the manifest tag. < uses-permission android: name = " android.permission.INTERNET " />

Adobe Reader Command Line Reference

Answer : You can find something about this in the Adobe Developer FAQ. (It's a PDF document rather than a web page, which I guess is unsurprising in this particular case.) The FAQ notes that the use of the command line switches is unsupported. To open a file it's: AcroRd32.exe <filename> The following switches are available: /n - Launch a new instance of Reader even if one is already open /s - Don't show the splash screen /o - Don't show the open file dialog /h - Open as a minimized window /p <filename> - Open and go straight to the print dialog /t <filename> <printername> <drivername> <portname> - Print the file the specified printer. I found this: http://www.robvanderwoude.com/commandlineswitches.php#Acrobat Open a PDF file with navigation pane active, zoom out to 50%, and search for and highlight the word "batch": AcroRd32.exe /A "zoom=50&navpanes=1=OpenActions&search=batch&q

Chmod 777 To A Folder And All Contents

Answer : If you are going for a console command it would be: chmod -R 777 /www/store . The -R (or --recursive ) options make it recursive. Or if you want to make all the files in the current directory have all permissions type: chmod -R 777 ./ If you need more info about chmod command see: File permission If by all permissions you mean 777 Navigate to folder and chmod -R 777 . You can give permission to folder and all its contents using option -R i.e Recursive permissions. But I would suggest not to give 777 permission to all folder and it's all contents. You should give specific permission to each sub-folder in www directory folders. Ideally, give 755 permission for security reasons to the web folder. sudo chmod -R 755 /www/store Each number has meaning in permission. Do not give full permission. N Description ls binary 0 No permissions at all --- 000 1 Only execute --x 001 2 Only write

Angular Start NgFor Index From 1

Answer : *ngFor="let item of items | slice:1; let i = index; SlicePipe There are 2 possible answers to the question, depending on what was actually being asked. If the intent is to skip the first element of the array, then the answers involving slice are in the right direction. However, if the intent is to simply shift the index while still iterating over all of the array, then slice is NOT the correct approach, as it will skip the 0th element in the array, thereby outputting only n-1 items from an array of length n . @Taylor gave a real-world example of when the index might need to be shifted for display purposes, such as when outputting a list where the first entry should read 1, not 0. Here's another similar example: <li *ngFor="let book of books; let i = index"> {{ i + 1 }}. {{ book.title }} </li> which would produce output like: Sample Book Title Another book title ... That's not possible, but you could use Arr

Button Class In Bootstrap Code Example

Example 1: bootstrap button < button type = " button " class = " btn btn-primary " > Primary </ button > < button type = " button " class = " btn btn-secondary " > Secondary </ button > < button type = " button " class = " btn btn-success " > Success </ button > < button type = " button " class = " btn btn-danger " > Danger </ button > < button type = " button " class = " btn btn-warning " > Warning </ button > < button type = " button " class = " btn btn-info " > Info </ button > < button type = " button " class = " btn btn-light " > Light </ button > < button type = " button " class = " btn btn-dark " > Dark </ button > < button type = " button " class = " btn btn-link " > Lin

Angular Ngclass Example

Example 1: ng class [ ngClass ] = "{'text-success':person.country === 'UK'}" Example 2: angular ngclass content_copy < some - element [ ngClass ] = "'first second'" > ... < / some - element > < some - element [ ngClass ] = "['first', 'second']" > ... < / some - element > < some - element [ ngClass ] = "{'first': true, 'second': true, 'third': false}" > ... < / some - element > < some - element [ ngClass ] = "stringExp|arrayExp|objExp" > ... < / some - element > < some - element [ ngClass ] = "{'class1 class2 class3' : true}" > ... < / some - element > Example 3: ngclass angular < div [ ngClass ] = " { 'green' : number > 5 , 'red' : number <= 5 , } " > < / div > //if the number is over 5, the class 'green'