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
| let jspdf = document.createElement("script"); | |
| jspdf.onload = function () { | |
| let pdf = new jsPDF(); | |
| let elements = document.getElementsByTagName("img"); | |
| for (let i in elements) { | |
| let img = elements[i]; | |
| if (!/^blob:/.test(img.src)) { | |
| continue; |
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
| # views.py | |
| # Use decorator require permission on Django | |
| from django.contrib.auth.decorators import permission_required | |
| @permission_required('product.manage_products') | |
| def product_list(request): | |
| pass |
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
| from django.test import TestCase | |
| from django.contrib.auth.models import User, Group, Permission | |
| from django.contrib.contenttypes.models import ContentType | |
| from django.contrib.auth import get_user_model | |
| # Create your tests here. | |
| class DjangoGroupPermissionTests(TestCase): | |
| def setUp(self): |
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
| # Init project Reactjs | |
| $ mkdir project-name | |
| $ cd project-name | |
| # create file package.json | |
| $ npm init | |
| # install webpack | |
| $ npm install --save webpack | |
| # Symbol |
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
| export const doIncrement = state => | |
| ({ counter: state.counter + 1 }); | |
| export const doDecrement = state => | |
| ({ counter: state.counter - 1 }); | |
| class Counter extends Component { | |
| state = { | |
| counter: 0, | |
| }; |
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
| // Source:https://www.robinwieruch.de/javascript-fundamentals-react-requirements/ | |
| import React, { Component } from 'react'; | |
| // function doFilter(query) { | |
| // return function (user) { | |
| // return query === user.name; | |
| // } | |
| // } | |
| const doFilter = query => user => |
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
| // Khi không sử dụng Arrow Function | |
| // this.age++; sẽ hiểu this = global chứ không phải là this.age trong Object Person | |
| function Person() { | |
| // The Person() constructor defines `this` as an instance of itself. | |
| this.age = 0; | |
| setInterval(function growUp() { | |
| // In non-strict mode, the growUp() function defines `this` | |
| // as the global object (because it's where growUp() is executed.), | |
| // which is different from the `this` |
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
| // Source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions | |
| var elements = [ | |
| 'Hydrogen', | |
| 'Helium', | |
| 'Lithium', | |
| 'Beryllium' | |
| ]; | |
| elements.map(function(element ) { | |
| return element.length; |
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
| // source: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions | |
| // Basic Syntax | |
| (param1, param2, …, paramN) => { statements } | |
| (param1, param2, …, paramN) => expression | |
| // equivalent to: => { return expression; } | |
| // Parentheses are optional when there's only one parameter name: | |
| (singleParam) => { statements } | |
| singleParam => { statements } |
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
| /** | |
| * In React, when you call super with props. | |
| * React will make props available across the component through this.props. | |
| * This allows us to call this.props.websites when the data is on the parent component. | |
| */ | |
| class App extends Component { | |
| constructor(props) { | |
| super(props); | |
| this.state = { websites: [] }; | |
| } |
NewerOlder