Posts

Showing posts from August, 2014

Ansible - Create Multiple Folders If Don't Exist

Answer : Using Ansible modules, you don't need to check if something exist or not, you just describe the desired state, so: - name: create directory if they don't exist file: path: "{{ item }}" state: directory owner: root group: root mode: 0775 loop: - /data/directory - /data/another Ansible - Creating multiple folders without changing permissions of previously existing. Working fine for me. Hope this works for you as well just try. --- - name: "Creating multiple by checking folders" hosts: your_host_name tasks: - block: - name: "Checking folders" stat: path: "{{item}}" register: folder_stats with_items: - ["/var/www/f1","/var/www/f2","/var/www/f3","/var/www/f4"] - name: "Creating multiple folders without disturbing previous permissions" file: path: "{{item.item}}" state: direc

Changing Background Color Of Text In Latex

Image
Answer : I know this question has been answered very extensively. But not what I wanted or thought was the question based on the title. Therefore if others get in here looking for a possibility for colouring behind a word than this snippet is much easier: \colorbox{blue!30}{blue} or \textcolor{blue!30}{blue} resulting in: This is possible by only adding \usepackage{xcolor} . Just some extra info :) Colour Several Lines It is correct that the above methods does not work for several lines, if you to be more than one line you can do: {\color{green} the text you want to write} This can however also be wrapped in a function so it is easier to use several places during edits, e.g., for colouring new text or whatever: \newcommand{\added}[1]{{\color{green}[added]:#1}} I prefer using tcolorbox thinking that in future you may want the background to be fashionable. I have given many options (which are not needed for this particular case) in the tcbset so that you can p

Can I Change The Look Of My Character In Destiny 2?

Answer : If you begin the story with your original character, this skips the customization options and goes into into the game. However, if you do choose to import a character, the game won’t give you the option to customize their appearance. I had the same struggle when I started Destiny 2, but unfortunately the only way to change the appearance of the characters that were synced from Destiny is to delete it and start from scratch. there’s no way to edit your appearance once the game starts. This means that once you leave the Destiny 2’s starting screen and customization options, you’re stuck with that look for the rest of the game. If you’re unhappy with your original character’s appearance, it’s best to create a new character from scratch. And if you’re creating a new one, make sure you’re happy with the way they look before moving forward. Source If you want to use your Destiny 1 character in Destiny 2, you must use it as-is - you can't customize your appearance. Y

Clamav Gui Windows Code Example

Example 1: clamav windows .\clamscan.exe . Example 2: clamav windows write.exe .\clamd.conf

Bootstrap 3 Popover Arrow And Box Positioning

Answer : You can customize the placement of the popover or it's arrow my manipulating the .popover CSS once the popover is shown. For example, this pushes the top of the popover down 22 pixels.. $('[data-toggle=popover]').on('shown.bs.popover', function () { $('.popover').css('top',parseInt($('.popover').css('top')) + 22 + 'px') }) Working demo : http://bootply.com/88325 I recommend using the placement method rather than the shown.bs.popover event. This will not trigger a popover jump when the element is shown. This is how it works: $('[data-toggle=popover]').popover({ placement: function(context, source) { var self = this; setTimeout(function() { self.$arrow.css('top', 55); self.$tip.css('top', -45); }, 0); return 'right'; }, }); My use case is that the popover placement is top and I have to remove the arrow. I followed the solution provide

Append Array Java Code Example

Example 1: java insert array // ! IMPORTANTE ! // in JAVA an array is not the same as an ArrayList object!! // 1 - declare, instanciate and populate int arr [ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 } ; // 2 - declare and instanciate an int array with maxSize // note: the index goes between 0 and maxSize-1 int newarr [ ] = new int [ maxSize ] ; // 2.1 - insert the value n on the position pos newarr [ pos ] = n ; // 2.2 - insert values recursively for ( i = 0 ; i < maxSize ; i ++ ) { newarr [ i ] = arr [ i ] ; } Example 2: how to append to an array in java import java . util . Arrays ; class ArrayAppend { public static void main ( String args [ ] ) { int [ ] arr = { 10 , 20 , 30 } ; System . out . println ( Arrays . toString ( arr ) ) ; arr = Arrays . copyOf ( arr , arr . length + 1 ) ; arr [ arr . length - 1 ] = 40 ; // Assign 40 to the last element System . out . p

Batch File For PuTTY/PSFTP File Transfer Automation

Answer : You need to store the psftp script (lines from open to bye ) into a separate file and pass that to psftp using -b switch: cd "C:\Program Files (x86)\PuTTY" psftp -b "C:\path\to\script\script.txt" Reference: https://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter6.html#psftp-option-b EDIT: For username+password: As you cannot use psftp commands in a batch file, for the same reason, you cannot specify the username and the password as psftp commands. These are inputs to the open command. While you can specify the username with the open command ( open <user>@<IP> ), you cannot specify the password this way. This can be done on a psftp command line only. Then it's probably cleaner to do all on the command-line: cd "C:\Program Files (x86)\PuTTY" psftp -b script.txt <user>@<IP> -pw <PW> And remove the open , <user> and <PW> lines from your script.txt . Reference: https://the.earth.li

C : Typedef Struct Name {...}; VS Typedef Struct{...} Name;

Answer : There are several things going on here. First, as others have said, the compiler's complaint about unknown type may be because you need to define the types before using them. More important though is to understand the syntax of 3 things: (1) struct definition, (2) struct declaration, and (3) typedef. When Defining a struct, the struct can be named, or unnamed (if unnamed, then it must be used immediately (will explain what this means further below)). struct Name { ... }; This defines a type called "struct Name" which then can be used to Declare a struct variable: struct Name myNameStruct; This declares a variable called myNameStruct which is a struct of type struct Name . You can also Define a struct, and declare a struct variable at the same time: struct Name { ... } myNameStruct; As before, this declares a variable called myNameStruct which is a struct of type struct Name ... But it does it at the same time it defines the type str

Can Scp Copy Directories Recursively?

Answer : Solution 1: Yup, use -r : scp -rp sourcedirectory user@dest:/path -r means recursive -p preserves modification times, access times, and modes from the original file. Note: This creates the sourcedirectory inside /path thus the files will be in /path/sourcedirectory Solution 2: While the previous answers are technically correct, you should also consider using rsync instead. rsync compares the data on the sending and receiving sides with a diff mechanism so it doesn't have to resend data that was already previously sent. If you are going to copy something to a remote machine more than once, use rsync . Actually, it's good to use rsync every time because it has more controls for things like copying file permissions and ownership and excluding certain files or directories. In general: $ rsync -av /local/dir/ server:/remote/dir/ will synchronize a local directory with a remote directory. If you run it a second time and the contents of the loca

Add Context Path To Spring Boot Application

Answer : Why are you trying to roll your own solution. Spring-boot already supports that. If you don't already have one, add an application.properties file to src\main\resources . In that properties file, add 2 properties: server.contextPath=/mainstay server.port=12378 UPDATE (Spring Boot 2.0) As of Spring Boot 2.0 (due to the support of both Spring MVC and Spring WebFlux) the contextPath has been changed to the following: server.servlet.contextPath=/mainstay You can then remove your configuration for the custom servlet container. If you need to do some post processing on the container you can add a EmbeddedServletContainerCustomizer implementation to your configuration (for instance to add the error pages). Basically the properties inside the application.properties serve as a default you can always override them by using another application.properties next to the artifact you deliver or by adding JVM parameters ( -Dserver.port=6666 ). See also The Reference

Apache Flink Vs Apache Spark As Platforms For Large-scale Machine Learning?

Answer : Disclaimer: I'm a PMC member of Apache Flink. My answer focuses on the differences of executing iterations in Flink and Spark. Apache Spark executes iterations by loop unrolling. This means that for each iteration a new set of tasks/operators is scheduled and executed. Spark does that very efficiently because it is very good at low-latency task scheduling (same mechanism is used for Spark streaming btw.) and caches data in-memory across iterations. Therefore, each iteration operates on the result of the previous iteration which is held in memory. In Spark, iterations are implemented as regular for-loops (see Logistic Regression example). Flink executes programs with iterations as cyclic data flows. This means that a data flow program (and all its operators) is scheduled just once and the data is fed back from the tail of an iteration to its head. Basically, data is flowing in cycles around the operators within an iteration. Since operators are just scheduled once, t
Note This plugin is part of the community.zabbix collection (version 1.2.0). To install it use: ansible-galaxy collection install community.zabbix . To use it in a playbook, specify: community.zabbix.zabbix_host . Synopsis Requirements Parameters Notes Examples Synopsis This module allows you to create, modify and delete Zabbix host entries and associated group and template data. Requirements The below requirements are needed on the host that executes this module. python >= 2.6 zabbix-api >= 0.5.4 Parameters Parameter Choices/Defaults Comments ca_cert string Required certificate issuer. Works only with >= Zabbix 3.0 aliases: tls_issuer description string Description of the host in Zabbix. force boolean Choices: no yes ← Overwrite the host configuration, even if already present. host_groups list / elements=string List of host groups the host is part of. host_name string / requi

++array In Arduino C Code Example

Example: variable array arduino var myArray[] = {d1,d2,d3,d4,d4}; var myArray[3]:

Alter Table Drop Column Oracle Code Example

Example 1: delete column from table oracle PL SQL ALTER TABLE table_name DROP COLUMN column_name; Example 2: oracle drop column ALTER TABLE my_table DROP COLUMN my_col; -- To check if column exists before renaming it: DECLARE l_cnt INTEGER; BEGIN SELECT count(*) INTO l_cnt FROM dba_tab_columns -- or all_tab_columns (depending on grants) WHERE owner = 'my_schema' AND table_name = 'my_table' AND column_name = 'my_col'; IF (l_cnt = 1) THEN EXECUTE IMMEDIATE 'ALTER TABLE my_schema.my_table DROP COLUMN my_col'; END IF; END; Example 3: oracle alter table delete column alter table table_name drop column column_name; alter table table_name drop (column_name1, column_name2);

After Upload A File In Android Firebase Storage How Get The File Download Url? GetDownloadUrl() Not Working

Answer : I had Found 2 solution for my issue. Firebase Google Documentation : //add file on Firebase and got Download Link filePath.putFile(imageUri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() { @Override public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception { if (!task.isSuccessful()){ throw task.getException(); } return filePath.getDownloadUrl(); } }).addOnCompleteListener(new OnCompleteListener<Uri>() { @Override public void onComplete(@NonNull Task<Uri> task) { if (task.isSuccessful()){ Uri downUri = task.getResult(); Log.d(TAG, "onComplete: Url: "+ downUri.toString()); } } }); Another solution! It's more easy and small than google Firebase documentation and I'll use it: filePath.putFile(imageUri).addOnSuccessListener(new OnSuccessListener<UploadTask.Task

Cmd Color Codes Not Working Python Code Example

Example 1: python color text on windows import termcolor import os os . system ( 'color' ) print ( termcolor . colored ( "I want to help" , "red" ) ) Example 2: how to change the color of command prompt in python import os # To get all possible colors for the command line, open the command prompt # and enter the command "color help" os . system ( 'color FF' )

Cannot Get Django-debug-toolbar To Appear

Answer : I had the same problem but managed to fix it following dvl's comment on this page. Here is a summary of the fix: In settings.py if DEBUG: MIDDLEWARE += ( 'debug_toolbar.middleware.DebugToolbarMiddleware', ) INSTALLED_APPS += ( 'debug_toolbar', ) INTERNAL_IPS = ('127.0.0.1', ) DEBUG_TOOLBAR_CONFIG = { 'INTERCEPT_REDIRECTS': False, } In the project urls.py, add this url pattern to the end: from django.conf import settings if settings.DEBUG: import debug_toolbar urlpatterns += [ url(r'^__debug__/', include(debug_toolbar.urls)), ] Some information for news users as me, when dev on virtual or remote machine Add this ligne in a views.py file print("IP Address for debug-toolbar: " + request.META['REMOTE_ADDR']) When the views is call, you can see the client IP in the shell You have to add this IP the settings.py file INTERNAL_IPS

Bootstrap Table Column Width Percentage Code Example

Example: bootstrap table col fixed width < table class = " table " > < thead > < tr > < th style = " width : 30 % " > Col 1 </ th > < th style = " width : 20 % " > Col 2 </ th > < th style = " width : 10 % " > Col 3 </ th > < th style = " width : 30 % " > Col 4 </ th > < th style = " width : 10 % " > Col 5 </ th > </ tr > </ thead > < tbody > < tr > < td > Val 1 </ td > < td > Val 2 </ td > < td > Val 3 </ td > < td > Val 4 </ td > < td > Val 5 </ td > </ tr > </ tbody > </ table >

Chemistry - Are Ionic Bonds Stronger Than Covalent Bonds?

Answer : Solution 1: In a fully covalent bond, you only have the mixing of the orbitals, as you said. But it's not only that, you also have coulomb interactions between the nuclei, that slightly raise the energy of the molecular orbitals, which results in asymmetric energies. In a fully ionic bond you also have a coulomb interaction, but this time with the different sign, because you have a positive and a negative charge. These want to be as close together as possible, resulting in a stronger bond. Generally speaking: Coulomb interactions have a greater impact than molecular orbitals on the energy, and thus the strength, of a bond. It's almost like saying that electromagnetic forces are stronger than gravitational forces. Solution 2: Two atoms will always (with a few corner-case exceptions) form the strongest bond between them that they can. If they form a covalent bond then that is because the covalent bond is stronger than the alternative ionic bond (at least a

Check If Port Is Open Command Line Linux Code Example

Example 1: linux how to see ports in use # Any of the following sudo lsof -i -P -n | grep LISTEN sudo netstat -tulpn | grep LISTEN sudo lsof -i:22 # see a specific port such as 22 sudo nmap -sTU -O IP-address-Here Example 2: check what ports are open linux ## if you use linux sudo ss -tulw

Cmd Create Text File Code Example

Example 1: write file using command windows echo some-text > filename.txt Example 2: make new file windows cmd type nul > README.txt Example 3: create a file cmd type NUL > EmptyFile.txt # also echo. 2>EmptyFile.txt copy nul file.txt > nul # also in qid's answer below REM. > empty.file fsutil file createnew file.cmd 0 # to create a file on a mapped drive Example 4: make text file command line cat > sample.txt # Write some text, press Ctrl+D when you are done Example 5: creating text file in cmd echo. > location with name