Posts

Showing posts from October, 2018

Angular: Convert XML To JSON

Image
Answer : If you use angular-cli to bootstrap your application - it comes already with node module to convert xml. https://github.com/Leonidas-from-XIV/node-xml2js So you do not need to add extra modules for this. As it is classic commonJS module - you need use require to import it: let parseString = require('xml2js').parseString; So your code can looks like: let parseString = require('xml2js').parseString; let xml = "<root>Hello xml2js!</root>" parseString(xml, function (err, result) { console.dir(result); }); You will receive next output: In any cases - if you even do not use angular-clior want to use your preffered module to parse xml - use require to load it. function parseXml(xmlStr) { var result; var parser = require('xml2js'); parser.Parser().parseString(xmlStr, (e, r) => {result = r}); return result; }

Componentdidmount Using React Hook Code Example

Example: react hooks componentdidmount // import useEffect from 'react'; useEffect ( ( ) => { // your code here } , [ ] ) ;

AccessDenied For ListObjectsV2 Operation For S3 Bucket

Answer : I'm not sure the accepted answer is actually acceptable , as it simply allows all operations on the bucket. Also the Sid is misleading... ;-) This AWS article mentions the required permissions for aws s3 sync . This is how a corresponding policy looks like: { "Version": "version_id", "Statement": [ { "Sid": "AllowBucketSync", "Effect": "Allow", "Action": [ "s3:GetObject", "s3:PutObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::BUCKET-NAME", "arn:aws:s3:::BUCKET-NAME/*" ] } ] } Try to update your bucket policy to: { "Version": "version_id", "Statement": [ { "Sid": "AllowPublicRead", "Effect": "Allow", &qu

Composer Require Guzzlehttp/guzzle Laravel 6 Code Example

Example 1: composer require guzzlehttp/guzzle To install guzzlehttp composer require guzzlehttp / guzzle Ref : https : // packagist . org / packages / guzzlehttp / guzzle Example 2: use guzzle http client laravel public function putGuzzleRequest ( ) { $client = new \GuzzleHttp\Client ( ) ; $url = "http://myexample.com/api/posts/1" ; $myBody [ 'name' ] = "Demo" ; $request = $client - > put ( $url , [ 'body' = > $myBody ] ) ; $response = $request - > send ( ) ; dd ( $response ) ; }

Can I Use .NET Reflector To Modify & Recompile The Code Quickly?

Answer : You can probably use the Reflexil add-in for Reflector to do that: Reflexil is an assembly editor and runs as a plug-in for Reflector. Using Mono.Cecil, Reflexil is able to manipulate IL code and save the modified assemblies to disk. Reflexil also supports 'on the fly' C# and VB.NET code injection. It's possible with .Net reflector along with reflexil. First download reflexiil and then open .net relector and load the reflexil into it using View->addins->select the reflexil file(all dlls) and then load. After that open the required dll file and go to tools->select reflectil, open the code and identify the required item, then edit..give to the assemblyy and select save as to save it to new file .NET Reflector cannot do this, but other tools can decompile .NET assemblies, for example FileDisassembler (an add-in for .NET Reflector).

Add Section Without Number Latex Table Of Contents Code Example

Example: latex section without number but in table of contents \section*{Section 1} \addcontentsline{toc}{section}{\protect\numberline{}Section 1}%

How To Change Color Of Hr Tag Html Code Example

Example 1: how to change the color of the hr tag in html <style > hr { height : 1 px ; background-color : #ccc ; border : none ; } </style> Example 2: change the color of an hr hr { height : 1 px ; background-color : #ccc ; border : none ; } Example 3: add color to hr tag border : 1 px solid red ;

C# Linq Foreach Select Code Example

Example 1: linq foreach c# sequence . Where ( x => x . Name . ToString ( ) . Equals ( "Apple" ) ) . ToList ( ) . ForEach ( x => { if ( someCondition ) { // Do some stuff here. } } ) ; Example 2: foreach c# linq example items . ToList ( ) . ForEach ( i => i . DoStuff ( ) ) ;

3D Glasses Giving The Opposite Effect To That Expected

Image
Answer : The others have already provided good explanations, but since it sounded like an interesting question and I already sketched up a diagram, I thought I would show it, too. As already mentioned, if you have an object that is to be shown as the exact same distance as the distance between you and the screen, it's very easy to represent that: It's just a single object on the screen that looks the same to both eyes. If, on the other hand, you want to show an object which is far away, then you need to 'trick' your eyes by showing two separate images on the screen, one for the left eye and another for the right eye. That's indicated by the two hollow green dots on the screen on the diagram below. And if you want to show an object which is closer to you than the actual screen distance, then to trick your eyes two images at the locations of the hollow blue dots need to be presented on screen. Note that for objects that are to appear closer than the screen distance

How To Select The Second Child In Css Code Example

Example 1: second child css .YourElementsClass :nth-child ( 2 ) { /* your styles */ } Example 2: nth-child() css /* Selects the second <li> element in a list */ li :nth-child ( 2 ) { color : lime ; } /* Selects every fourth element among any group of siblings */ :nth-child ( 4n ) { color : lime ; } Example 3: css nth child :nth-child ( 1 ) { /*advantage is you can do it for 2nd, 3rd etc. */ /* styles go here*/ } Example 4: how select two nt child with css //Separate the classes with a comma , .ListTaskTime tbody tr > td :nth-child ( 3 ) , .ListTaskTime tbody tr > td :nth-child ( 6 ) , .ListTaskTime tbody tr > td :nth-child ( 9 ) { /* Common Styles Goes Here, Styles will apply to child 3,6 and 9 */ }

Html &nbsp New Line Code Example

Example: how to make new line in html paragraph <p> Will Mateson<br /> Box 61 <br /> Cleveland , Ohio<br /> </p>

Cordova Android Requirements Failed: "Could Not Find An Installed Version Of Gradle"

Answer : Solution for linux with apt-get (eg.: Ubuntu, Debian) I have quite similar problem. I obtained error: Error: Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studi but without Exception. I solved it on Ubuntu by sudo apt-get install gradle I found also commands that allows install newest version of gradle in Ubuntu. It works only when first command is executed before (probably some dependecies are incorrect). sudo add-apt-repository ppa:cwchien/gradle sudo apt-get update sudo apt-get install gradle-ppa https://wtanaka.com/node/8079 If it does not work, try: export PATH=$PATH:/opt/gradle/gradle-3.5/bin More info: https://askubuntu.com/questions/915980/package-is-installed-and-is-not-detected-gradle/915993#915993 For CentOS Instruction of instalation gradle for CentOS is under this link https://gist.github.com/parzonka/9371885 Update Now I inst

Can I Use Array_push On A SESSION Array In Php?

Answer : Yes, you can. But First argument should be an array. So, you must do it this way $_SESSION['names'] = array(); array_push($_SESSION['names'],$name); Personally I never use array_push as I see no sense in this function. And I just use $_SESSION['names'][] = $name; Try with if (!isset($_SESSION['names'])) { $_SESSION['names'] = array(); } array_push($_SESSION['names'],$name);

Kite App Download For Pc Code Example

Example: kite download I think this is a very nice software , but i also on the same hand i prefer learning the snippets through practice

-9f 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 ) ; } }