Posts

Showing posts from November, 2006

Ansible Include Task Only If File Exists

Answer : The with_first_found conditional can accomplish this without a stat or local_action . This conditional will go through a list of local files and execute the task with item set to the path of the first file that exists. Including skip: true on the with_first_found options will prevent it from failing if the file does not exist. Example: - hosts: localhost connection: local gather_facts: false tasks: - include: "{{ item }}" with_first_found: - files: - /home/user/optional/file.yml skip: true Thanks all for your help! I'm aswering my own question after finally trying all responses and my own question's code back in today's Ansible: ansible 2.0.1.0 My original code seems to work now, except the optional file I was looking was in my local machine, so I had to run stat through local_action and set become: no for that particular tasks, so ansible wouldn't attempt to do sudo in my local machine

Apple - Change Shortcut To Change Input Source (keyboard Language)

Answer : Here are Apple's instructions for changing shortcuts found in PH21531: Choose Apple menu > System Preferences, click Keyboard, then click Shortcuts. Select the action (Input Sources in your case) in the list that you want to change. Double-click the current shortcut, then press the new key combination you want to use. You cannot use each type of key (for example, a letter key) more than once in a key combination. Quit and restart any apps you’re using for the new keyboard shortcut to take effect.

C Volatile Type Qualifier Example

Each individual type in the C type system has several qualified versions of that type, corresponding to one, two, or all three of the const, volatile , and, for pointers to object types, restrict qualifiers. This page describes the effects of the volatile qualifier. Every access (both read and write) made through an lvalue expression of volatile-qualified type is considered an observable side effect for the purpose of optimization and is evaluated strictly according to the rules of the abstract machine (that is, all writes are completed at some time before the next sequence point). This means that within a single thread of execution, a volatile access cannot be optimized out or reordered relative to another visible side effect that is separated by a sequence point from the volatile access. A cast of a non-volatile value to a volatile type has no effect. To access a non-volatile object using volatile semantics, its address must be cast to a pointer-to-volatile and then the acce

How To Know The Array Length In C Code Example

Example 1: size of an array c int a [ 20 ] ; int length ; length = sizeof ( a ) / sizeof ( int ) ; Example 2: array length c int prices [ 5 ] = { 1 , 2 , 3 , 4 , 5 } ; int size = sizeof prices / sizeof prices [ 0 ] ; printf ( "%u" , size ) ; /* 5 */ Example 3: get length of array in c int a [ 17 ] ; size_t n = sizeof ( a ) / sizeof ( a [ 0 ] ) ;

Bulma Icon Not Showing Up?

Answer : You also need to include the bulma.min.css file, not just the .map . Edit Per the Bulma docs: If you want to use icons with Bulma, don't forget to include Font Awesome: <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> Update 3/19/2019 As @Akshay has pointed out below, the documentation has changed and the proper way to include Font Awesome is now <script defer src="https://use.fontawesome.com/releases/v5.3.1/js/all.js"></script>

C Puts() Without Newline

Answer : Typically one would use fputs() instead of puts() to omit the newline. In your code, the puts(input); would become: fputs(input, stdout); puts() adds the newline character by the library specification. You can use printf instead, where you can control what gets printed with a format string: printf("%s", input); You can also write a custom puts function: #include <stdio.h> int my_puts(char const s[static 1]) { for (size_t i = 0; s[i]; ++i) if (putchar(s[i]) == EOF) return EOF; return 0; } int main() { my_puts("testing "); my_puts("C puts() without "); my_puts("newline"); return 0; } Output: testing C puts() without newline

Array Splicing In Javascript Code Example

Example 1: javascript splice let arr = [ 'foo' , 'bar' , 10 , 'qux' ] ; // arr.splice(<index>, <steps>, [elements ...]); arr . splice ( 1 , 1 ) ; // Removes 1 item at index 1 // => ['foo', 10, 'qux'] arr . splice ( 2 , 1 , 'tmp' ) ; // Replaces 1 item at index 2 with 'tmp' // => ['foo', 10, 'tmp'] arr . splice ( 0 , 1 , 'x' , 'y' ) ; // Inserts 'x' and 'y' replacing 1 item at index 0 // => ['x', 'y', 10, 'tmp'] Example 2: splice javascript let arrDeletedItems = arr . splice ( start [ , deleteCount [ , item1 [ , item2 [ , . . . ] ] ] ] )

Bootstrap 3 Margin Bottom And Top Class Name Code Example

Example 1: bootstrap Margin and padding Use the margin and padding spacing utilities to control how elements and components are spaced and sized. Bootstrap 4 includes a five-level scale for spacing utilities, based on a 1rem value default $spacer variable. Choose values for all viewports (e.g., .mr-3 for margin-right: 1rem), or pick responsive variants to target specific viewports (e.g., .mr-md-3 for margin-right: 1rem starting at the md breakpoint). < div class = " my-0 bg-warning " > Margin Y 0 </ div > < div class = " my-1 bg-warning " > Margin Y 1 </ div > < div class = " my-2 bg-warning " > Margin Y 2 </ div > < div class = " my-3 bg-warning " > Margin Y 3 </ div > < div class = " my-4 bg-warning " > Margin Y 4 </ div > < div class = " my-5 bg-warning " > Margin Y 5 </ div > < div class = " my-auto bg-warning &q

Code Block In Discord Code Example

Example 1: format code discord ```my language my code ``` Example 2: css discord color guide Default : # 839496 ``` NoKeyWordsHere ``` Quote : # 586e75 ```brainfuck NoKeyWordsHere ``` Solarized Green : # 859900 ```CSS NoKeyWordsHere ``` Solarized Cyan : # 2 aa198 ```yaml NoKeyWordsHere ``` Solarized Blue : # 268 bd2 ```md NoKeyWordsHere ``` Solarized Yellow : #b58900 ```fix NoKeyWordsHere ``` Solarized Orange : #cb4b16 ```glsl NoKeyWordsHere ``` Solarized Red : #dc322f ```diff - NoKeyWordsHere ``` Example 3: css discord color guide And here is the escaped Default : # 839496 ``` This is a for statement ``` Quote : # 586e75 ```bash # This is a for statement ``` Solarized Green : # 859900 ```diff + This is a for statement ``` //Second Way to do it ```diff ! This is a for statement ``` Solarized Cyan : # 2 aa198 ```cs "This is a for statement" ``` ```cs 'This is a for statement' ``` Solarized Blue : # 268 bd2 ```ini [ This

How To Determine The Length Of An Array In C Code Example

Example 1: size of an array c int a [ 20 ] ; int length ; length = sizeof ( a ) / sizeof ( int ) ; Example 2: array length c int prices [ 5 ] = { 1 , 2 , 3 , 4 , 5 } ; int size = sizeof prices / sizeof prices [ 0 ] ; printf ( "%u" , size ) ; /* 5 */

1 Hour 20 Minutes Timer Code Example

Example 1: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds Example 2: 20 minute timer For the 20/20/20 rule you can also close your eyes for 20 seconds and get the same results because it relaxes the mucles in your eyes.

BASH COUNTER Code Example

Example 1: increment number bash i = $(( i + 1 )) (( i = i + 1 )) let "i=i+1" Example 2: bash counter i = 22 i = $(( i + 1 )) #double param

Yutube .com Code Example

Example 1: youtube.com boredom = input ( "Are you bored? (enter yes or no)" ) if boredom.upper ( ) == 'YES' or boredom.upper ( ) == 'Y' : print ( "Hey, maybe you should go on Youtube..." ) else: print ( "I see you have no time for Youtube then... :'(" ) Example 2: youtube.com press ctrl + l and type 'youtube.com'

Add Element To Numpy Array Code Example

Example 1: numpy append number to array import numpy as np a = np . array ( [ 1 , 2 , 3 ] ) newArray = np . append ( a , [ 10 , 11 , 12 ] ) Example 2: append value to numpy array x = np . random . randint ( 2 , size = 10 ) x = np . append ( x , 2 ) Example 3: np append row A = [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] ] np . append ( A , [ [ 7 , 8 , 9 ] ] , axis = 0 ) >> array ( [ [ 1 , 2 , 3 ] , [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ) #or np . r_ [ A , [ [ 7 , 8 , 9 ] ] ] Example 4: how to add numpy arrays added = a + b #elementwise added_in_the_end = np . concatenate ( a , b ) #add at the end of the array # if you want to add in multiple dimentions check the documentation of np . concatenate Example 5: add item to numpy array python >>> np . append ( [ 1 , 2 , 3 ] , [ [ 4 , 5 , 6 ] , [ 7 , 8 , 9 ] ] ) array ( [ 1 , 2 , 3 , ... , 7 , 8 , 9 ] ) Example 6: add item to numpy array py

How To Serial Print A Byt In Arduino Code Example

Example: how to print to the serial monitor arduino void setup ( ) { Serial . begin ( 9600 ) ; } void loop ( ) { // This will write to the monitor and end the line Serial . println ( "test text" ) ; // This will write to the monitor but will not end the line Serial . print ( "test text" ) ; }

Coinbase Pro Login Code Example

Example: coinbase pro docs [ { "maker_fee_rate": "0.0015", "taker_fee_rate": "0.0025", "usd_volume": "25000.00" } ]

Access Parent URL From Iframe

Answer : Yes, accessing parent page's URL is not allowed if the iframe and the main page are not in the same (sub)domain. However, if you just need the URL of the main page (i.e. the browser URL), you can try this: var url = (window.location != window.parent.location) ? document.referrer : document.location.href; Note: window.parent.location is allowed; it avoids the security error in the OP, which is caused by accessing the href property: window.parent.location.href causes "Blocked a frame with origin..." document.referrer refers to "the URI of the page that linked to this page." This may not return the containing document if some other source is what determined the iframe location, for example: Container iframe @ Domain 1 Sends child iframe to Domain 2 But in the child iframe... Domain 2 redirects to Domain 3 (i.e. for authentication, maybe SAML), and then Domain 3 directs back to Domain 2 (i.e. via form submissi

Clear Workspace R Code Example

Example 1: r remove all environment rm(list = ls()) Example 2: how to clear rstudio environment click on the brush icon in environment tab

AH00161: Server Reached MaxRequestWorkers Setting, Consider Raising The MaxRequestWorkers Setting

Answer : Basically config got overwritten in: /etc/apache2/mods-available/mpm_prefork.conf I put the new setting in that file and it seems Apache works correctly now. Hopefully this helps someone else, don't put your config straight in apache2.conf or httpd.conf. Make sure you change all loaded config files. you should edit mpm_prefork <IfModule mpm_prefork_module> StartServers 10 MinSpareServers 10 MaxSpareServers 20 ServerLimit 2000 MaxRequestWorkers 1500 MaxConnectionsPerChild 10000 </IfModule> You modified the wrong file. Your log says "mpm_prefork" error. So you need to modify mpm_prefork.conf rather than mpm_worker.conf. You can also use "apachectl -M" to see what module you are using. e.g. My apache2 is using mpm_event_module, so i need to modify mpm_event.conf $ apache2ctl -M Loaded Modules: core_module (static) s

Android Button Drawable Tint

Image
Answer : You can achieve coloring the drawableleft on a button with this method: Step 1: Create a drawable resource file with bitmap as parent element as shown below and name it as ic_action_landscape.xml under the drawable folder <?xml version="1.0" encoding="utf-8"?> <bitmap xmlns:android="http://schemas.android.com/apk/res/android" android:src="@android:drawable/ic_btn_speak_now" android:tint="@color/white" /> Step 2: Create your Button control in your layout as below <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:backgroundTint="@color/md_light_green_500" android:drawableLeft="@drawable/ic_action_landscape" android:drawablePadding="8dp" android:fontFamily="sans-serif" android:gravity="left|center_vertical" android:stateListAn

80f To C Code Example

Example: convert fahrenheit to celsius import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int far = sc . nextInt ( ) ; int cel = ( far - 32 ) * 5 / 9 ; System . out . printf ( "%d Fahrenheit is %d Celsius" , far , cel ) ; } }

Android:fitsSystemWindows Not Working

Answer : Use CoordinatorLayout as root for your view, it worked for me. <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true"> My problem was most likely related to multiple/nested fitsSystemWindows attributes which does not work as I found out later. I solved my problem by applying the attribute to one view, and then copy the paddings to other views that need them via an ViewTreeObserver.OnGlobalLayoutListener . That is an ugly hack, but does its job for now. I meet the same problem in Android 4.4 My problem is <item name="android:windowTranslucentStatus">true</item> conflict with <item name="android:fitsSystemWindows">true</item> My way is remove