This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { async, TestBed } from '@angular/core/testing'; | |
import { Observable, of } from 'rxjs'; | |
import { AppComponent } from './app.component'; | |
import { HerbsService } from './herbs.service'; | |
import { RouterTestingModule } from '@angular/router/testing'; | |
class MockService { | |
mockRespone = { | |
data: [ | |
{ id: 1, name: 'hello' }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = "How good is have account on StackOverflow and create new posts" | |
def odd(data): | |
idx, el = data | |
return el if idx % 2 == 0 else el + "\n" | |
print(" ".join(list(map(odd, list(enumerate(string.split(" "))))))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.range = function(start, stop) { | |
let d = []; | |
for (let i = start; i <= stop; i++) { | |
d.push(i); | |
} | |
return d; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let products = [ | |
{ name: "Hat", price: 24.5, stock: 10 }, | |
{ name: "Kayak", price: 289.99, stock: 1 }, | |
{ name: "Soccer Ball", price: 10, stock: 0 }, | |
{ name: "Running Shoes", price: 116.50, stock: 20 } | |
]; | |
console.log( | |
products.map(item => ({name: item.name, price: item.price * 2, stock: item.stock})) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.http | |
.get(url) | |
.subscribe( | |
result => { | |
this.dataStore.listItems = result; | |
this._listItems.next(result); | |
}, | |
error => { | |
console.log('error'); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// super awesome keybindings for proffesionals | |
[ | |
// prevent quiting app when type | |
{ | |
"key": "ctrl+q", | |
"command": "-workbench.action.quit" | |
}, | |
// add new file when focused on sidebar | |
{ | |
"key": "ctrl+n", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The goal is to create function, that displays in console numbers from 0 to 9. After every number, we want little timeout.*/ | |
// this only prints 10 ten times | |
for (let i = 0; i < 10; i++) { | |
setTimeout(() => { | |
console.log(i); | |
}, i * 1000) | |
} | |
//with arrow fn, also doesn't work |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Person(first, last, age, gender, interests) { | |
this.name = { | |
first, | |
last | |
}; | |
this.age = age; | |
this.gender = gender; | |
this.interests = interests; | |
} | |
// declare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mycompany.myapp.web.rest.controller; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
import com.mycompany.myapp.models.Article; | |
import com.mycompany.myapp.repository.ArticleRepository; | |
import com.mycompany.myapp.service.ArticleService; | |
import org.junit.Test; | |
import org.junit.runner.RunWith; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ResponseBody | |
@RequestMapping( | |
method = RequestMethod.GET, | |
value="test", | |
produces = MediaType.APPLICATION_XML_VALUE | |
) | |
public ResponseEntity<String>testXML(){ | |
return ResponseEntity.ok("<xml></xml>); // inside use string creating xml data | |
} |