This file contains hidden or 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
var val = await new Promise((res, rej) => { | |
res('something') | |
}); | |
// val === 'something' | |
// this is equivalent to | |
var val; | |
new Promise((res, rej) => { | |
res('something'); |
This file contains hidden or 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
def get_text_from_file(file_path): | |
value = None | |
try: | |
with open(file_path, mode='r') as file: | |
value = file.read() | |
except UnicodeDecodeError: | |
try: | |
with open(file_path, mode='rb') as file: | |
value = file.read() | |
except: |
This file contains hidden or 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 {inject} from 'aurelia-framework'; | |
import $ from 'jQuery'; // i'm not sure about this line, check the jquery site or stack overflow. $ should be defined. | |
import 'materialize-css'; // this will load the materialize library | |
@inject(Element) | |
export class CollapsibleCustomAttribute { | |
private element; | |
constructor(element) { | |
this.element = $(element); |
This file contains hidden or 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 { inject, Aurelia, View } from 'aurelia-framework'; | |
@inject(Aurelia, Element) | |
export class DFCustomElement { | |
constructor(aurelia, element) { | |
this.container = aurelia.container; | |
this.element = element; | |
} |
This file contains hidden or 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
a = [1,2,3] // [1, 2, 3] | |
b = [4,5] // [4, 5] | |
c = a.slice() // [1, 2, 3] | |
c.push(b) // 4 | |
JSON.stringify(c) // "[1,2,3,[4,5]]" | |
JSON.stringify([...a, ...b]) // "[1,2,3,4,5]" |
This file contains hidden or 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
<template> | |
<nav class="sidebar ${isOpen ? 'open' : 'closed'}"> | |
<button click.delegate="toggle()"> | |
hamburger | |
</button> | |
</nav> | |
<main class="main"></main> | |
</template> |
This file contains hidden or 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 { inject } from 'aurelia-framework'; | |
@inject(Element) | |
export class CustomDroppableCustomAttribute { | |
constructor(Element) { | |
this.element = Element; | |
} | |
attached() { |
This file contains hidden or 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
<template> | |
<!-- For this specific case, I recommend using a parent css selector. It has nothing to | |
do with Aurelia, mostly, but it's clean and performant. The isDropping property is set | |
through the drag event handlers on the row, similar to what you described with | |
isHoveringSection --> | |
<style> | |
dropzone { | |
display: none; | |
} |
This file contains hidden or 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 { inject } from 'aurelia-framework'; | |
import { HttpClient, json } from 'aurelia-http-client'; | |
// Let's build a very basic service to interface with our Places WebApi project. | |
@inject(HttpClient) | |
export class PlaceService { | |
http; | |
This file contains hidden or 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
<template> | |
<div>Book: ${MediaType['Book']}</div> | |
</template> |
OlderNewer