Posts

Showing posts from April, 2015

Adding Git-Bash To The New Windows Terminal

Image
Answer : Overview Open settings with ctrl + , You'll want to append one of the profiles options below (depending on what version of git you have installed) to the "list": portion of the settings.json file { "$schema": "https://aka.ms/terminal-profiles-schema", "defaultProfile": "{00000000-0000-0000-ba54-000000000001}", "profiles": { "defaults": { // Put settings here that you want to apply to all profiles }, "list": [ <put one of the configuration below right here> ] } } Profile options Uncomment correct paths for commandline and icon if you are using: Git for Windows in %PROGRAMFILE% Git for Windows in %USERPROFILE% If you're using scoop { "guid": "{00000000-0000-0000-ba54-000000000002}", "commandline": "%PROGRAMFILES%/git/usr/bin/bash.ex

Boolean Default Value Code Example

Example 1: default boolean value java Default values for variable types: Object = null int, double, long, (etc) = 0 boolean = false char = '\u0000' Example 2: is a bool false by default The default value for a boolean is false.

Change Image Alignment Html Code Example

Example: html css center image < div style = "text-align: center;" > < img scr = 'img/example.jpg' > < / div >

Vue Router Get Query Params Code Example

Example 1: query params vuejs http : //localhost:8000?name=John&email=john@gmail.com parameters = this . $route . query console . log ( parameters ) name = this . $route . query . name console . log ( name ) Example 2: url params vue //we can configure the routes to receive data via the url //first configure the route so it can receive data: const routes = [ . . { path : '/page/:id?' , name = 'page' , component : Page } , . . //inside the Page component we can get the data: name : 'Page' , mounted ( ) { this . url_data = this . $route . params . id ; } , data ( ) { return { url_data : null } ; } //the data can be then used in the template section of the component < h2 > { { url_data } } < / h2 > Example 3: get params from route vuejs const User = { template : '<div>User {{ $route.params.id }}</div>' } Example 4: vue router url string

Bash: Npm: Command Not Found?

Answer : Just go into npm page and follow the instructions. If you have already installed nodejs and still getting this error. npm: command not found.. run this apt-get install -y npm I also come here for the same problem, The solution I found is to install npm and then restart the Visual Studio Code

Boot Ubuntu 16.04 Into Command Line / Do Not Start GUI

Answer : You could disable the display manager service with systemctl . For example if your display manager is lightdm then run: sudo systemctl disable lightdm.service This will prevent the service from starting at boot. Edit : I forgot to mention how to start the GUI. It is as simple as starting the systemd service: sudo systemctl start lightdm.service Instead of text use runlevel 3 : GRUB_CMDLINE_LINUX="3" # To remove all the fancy graphics you need to get rid of `splash`. GRUB_CMDLINE_LINUX_DEFAULT=”quiet” # Uncomment to disable graphical terminal (grub-pc only) GRUB_TERMINAL=console Then update-grub and reboot. But you really only need GRUB_CMDLINE_LINUX="3" . For quick test hit ESC during booting to get into the grub boot menu. Then press e and find the line which specifies kernel and add 3 at the end: linux /vmlinuz root=/dev/mapper/ubuntu ro 3 Boot it with CTRL + x Ideally I also want to be able to start GUI by typ

Count Letters In String Python Code Example

Example 1: count characters in string python >> > sentence = 'Mary had a little lamb' >> > sentence . count ( 'a' ) 4 Example 2: check how many letters in a string python # use the built in function len ( ) len ( "hello" ) # or you can count the characters in a string variable a = "word" len ( a )

Arduino Switch Case In Switch Case Code Example

Example 1: swich case arduino // Arduino => c++ switch ( var ) { case 1 : //do something when var equals 1 break ; case 2 : //do something when var equals 2 break ; default : // if nothing else matches, do the default // default is optional break ; } Example 2: arduino switch case switch ( var ) { case label1 : // statements break ; case label2 : // statements break ; default : // statements break ; }

Add 10 Seconds To A Date

Answer : There's a setSeconds method as well: var t = new Date(); t.setSeconds(t.getSeconds() + 10); For a list of the other Date functions, you should check out MDN setSeconds will correctly handle wrap-around cases: var d; d = new Date('2014-01-01 10:11:55'); alert(d.getMinutes() + ':' + d.getSeconds()); //11:55 d.setSeconds(d.getSeconds() + 10); alert(d.getMinutes() + ':0' + d.getSeconds()); //12:05 // let timeObject = new Date(); // let milliseconds= 10 * 1000; // 10 seconds = 10000 milliseconds timeObject = new Date(timeObject.getTime() + milliseconds); Just for the performance maniacs among us. getTime var d = new Date('2014-01-01 10:11:55'); d = new Date(d.getTime() + 10000); 5,196,949 Ops/sec, fastest setSeconds var d = new Date('2014-01-01 10:11:55'); d.setSeconds(d.getSeconds() + 10); 2,936,604 Ops/sec, 43% slower moment.js var d = new moment('2014-01-01 10:11:55'); d = d.add(10,

Appending An Element To The End Of A List In Scala

Answer : List(1,2,3) :+ 4 Results in List[Int] = List(1, 2, 3, 4) Note that this operation has a complexity of O(n). If you need this operation frequently, or for long lists, consider using another data type (e.g. a ListBuffer). That's because you shouldn't do it (at least with an immutable list). If you really really need to append an element to the end of a data structure and this data structure really really needs to be a list and this list really really has to be immutable then do eiher this: (4 :: List(1,2,3).reverse).reverse or that: List(1,2,3) ::: List(4) Lists in Scala are not designed to be modified. In fact, you can't add elements to a Scala List ; it's an immutable data structure , like a Java String. What you actually do when you "add an element to a list" in Scala is to create a new List from an existing List . (Source) Instead of using lists for such use cases, I suggest to either use an ArrayBuffer or a ListBuffer . Those data

ASP Core WebApi Test File Upload Using Postman

Image
Answer : Thanks to @rmjoia's comment I got it working! Here is what I had to do in Postman: The complete solution for uploading file or files is shown below: This action use for uploading multiple files : // Of course this action exist in microsoft docs and you can read it. HttpPost("UploadMultipleFiles")] public async Task<IActionResult> Post(List<IFormFile> files) { long size = files.Sum(f => f.Length); // Full path to file in temp location var filePath = Path.GetTempFileName(); foreach (var formFile in files) { if (formFile.Length > 0) using (var stream = new FileStream(filePath, FileMode.Create)) await formFile.CopyToAsync(stream); } // Process uploaded files return Ok(new { count = files.Count, path = filePath}); } The postman picture shows how you can send files to this endpoint for uploading multiple files: This action use for uploading single file : [Http

Bash Regex Capture Group

Answer : It's a shame that you can't do global matching in bash. You can do this: global_rematch() { local s=$1 regex=$2 while [[ $s =~ $regex ]]; do echo "${BASH_REMATCH[1]}" s=${s#*"${BASH_REMATCH[1]}"} done } global_rematch "$mystring1" "$regex" 1BBBBBB 2AAAAAAA This works by chopping the matched prefix off the string so the next part can be matched. It destroys the string, but in the function it's a local variable, so who cares. I would actually use that function to populate an array: $ mapfile -t matches < <( global_rematch "$mystring1" "$regex" ) $ printf "%s\n" "${matches[@]}" 1BBBBBB 2AAAAAAA To get the second array value, you need to have a second set of parentheses in the regex: mystring1='<link rel="self" href="/api/clouds/1/instances/1BBBBBB"/> dsf <link rel="self" href="/api/cloud

Cdn For Bootstrap Grid Code Example

Example: bootstrap latest version cdn <! doctype html > < html lang = " en " > < head > <!-- Required meta tags --> < meta charset = " utf-8 " > < meta name = " viewport " content = " width=device-width, initial-scale=1, shrink-to-fit=no " > <!-- Bootstrap CSS --> < link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css " integrity = " sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z " crossorigin = " anonymous " > < title > Hello, world! </ title > </ head > < body > < h1 > Hello, world! </ h1 > <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> < script src = " https://code.jquery.com/jquery-3.5.1.slim.min.js " i

Check Length Of Object In Javascript Code Example

Example 1: javascript object length var size = Object . keys ( myObj ) . length ; Example 2: length of an object in javascript //length of this object is 4 let object = { 'A' : { '10' : [ 'a' , 'b' , 'c' ] } , 'B' : { '20' : [ 'a' , 'b' , 'c' ] } , 'C' : { '30' : [ 'a' , 'b' , 'c' ] } , 'D' : { '40' : [ 'a' , 'b' , 'c' ] } , } //Get the keys of the object (A,B,C,D) and print how many there are Object . keys ( ) . length > prints : 4

Bootstrap 4 Ul Li List Style None Code Example

Example 1: list style none bootstrap <ul> <li className= "list-unstyled" >Facebook</li> <li className= "list-unstyled" >Youtube</li> <li className= "list-unstyled" >Instagram</li> </ul> Example 2: bootstrap ul no style <ul class= "list-unstyled" > <li>...</li> </ul>