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
export NODE_VER=14.15.1 | |
if ! node --version | grep -q ${NODE_VER}; then | |
(cat /proc/cpuinfo | grep -q "Pi Zero") && if [ ! -d node-v${NODE_VER}-linux-armv6l ]; then | |
echo "Installing nodejs ${NODE_VER} for armv6 from unofficial builds..." | |
curl -O https://unofficial-builds.nodejs.org/download/release/v${NODE_VER}/node-v${NODE_VER}-linux-armv6l.tar.xz | |
tar -xf node-v${NODE_VER}-linux-armv6l.tar.xz | |
fi | |
echo "Adding node to the PATH" | |
PATH=$(pwd)/node-v${NODE_VER}-linux-armv6l/bin:${PATH} | |
fi |
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
const events = [download, download2]; | |
const promises = events.map((event) => { | |
return new Promise((resolve) => { | |
event.on("end", (paths) => { | |
resolve(paths); | |
}); | |
}); | |
}); | |
Promise.all(promises).then((result) => {}); |
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
/** | |
* Shuffles array in place. ES6 version | |
* @param {Array} a items An array containing the items. | |
* https://stackoverflow.com/questions/6274339/how-can-i-shuffle-an-array | |
*/ | |
shuffle(a: Array<any>) { | |
for (let i = a.length - 1; i > 0; i--) { | |
const j = Math.floor(Math.random() * (i + 1)); | |
[a[i], a[j]] = [a[j], a[i]]; | |
} |
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
/** | |
* Makes a copy of values not references and goes down the attributes | |
*/ | |
deepCopy(o) { | |
var copy = o, | |
k; | |
if (o && typeof o === "object") { | |
copy = | |
Object.prototype.toString.call(o) === "[object Array]" |
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
/** | |
* Generates a random integer between min and max (inclusive) | |
* @param {number} min | |
* @param {number} max | |
* @returns randomly generated integer | |
*/ | |
public randomInt = (min: number, max: number): number => { | |
return Math.floor(Math.random() * (max - min + 1) + min); | |
}; |
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
describe('CompanyPage', () => { | |
it('renders correctly', () => { | |
expect( | |
renderWithProviders( | |
withRouter( | |
<CompanyPage companies={testCompanies} avgSalaries={testSalaries} /> | |
) | |
).baseElement | |
).toMatchSnapshot(); | |
}); |
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 time | |
times = 5000000 | |
def func1(): | |
return 5 + 5 | |
def func2(): | |
return 5 + 5 - 5 + 5 |
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
#!/usr/bin/env python3 | |
phrase = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer non lorem nec ante commodo gravida. Aenean ut ultricies quam. Nullam euismod lorem quis dapibus pharetra. Vestibulum a tincidunt justo. Proin eget faucibus velit. Aenean tincidunt lorem non ex molestie gravida vitae feugiat diam. In venenatis lacus non ipsum convallis porttitor nec vitae erat. Proin auctor, nibh ac hendrerit tempor, arcu lacus interdum erat, sit amet hendrerit mi dolor nec sapien. Maecenas mi dui, viverra ac imperdiet et, auctor id libero. Nunc sit amet felis lacus. Nunc vitae erat sit amet nunc porttitor lacinia vitae nec neque. Praesent tortor diam, molestie volutpat rhoncus et, fermentum a odio. Etiam et felis eget purus semper fermentum. In finibus ex in convallis pellentesque. Praesent fringilla massa ac dictum malesuada. Maecenas nec massa vitae mi porta sodales. Aenean blandit massa vitae leo finibus venenatis. In hac habitasse platea dictumst. Suspendisse eget orci ultrices justo malesua |
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
props.setMembers([ | |
...props.members.map((el, index) => { | |
if (el.id == props.editThisOne.id) { | |
el = member; | |
} | |
return el; | |
}) | |
]); | |
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
const person = { | |
name: 'Rodrigo', | |
age: 99, | |
how_old: function() { return this.name + ' is ' + this.age + ' old'} | |
} | |
person.how_old() | |
// Why dont arrow functions work with this? | |
// How do you solve it? | |
const person2 = { |
NewerOlder