Skip to content

Instantly share code, notes, and snippets.

View alestrunda's full-sized avatar
🏠
Working from home

Aleš Trunda alestrunda

🏠
Working from home
View GitHub Profile
@alestrunda
alestrunda / performance-memory.js
Last active January 10, 2023 10:14
Performace Testing - Memory
// create milions of objects and save them into an array to keep the reference
// how much memory is available depends on the system, remove some of the 'objects' arrays if it crashes
// note: better to use a few arrays instead of putting everything in one - you might actually hit the limit of an array, not the memory limit
function objectFactory(id) {
return {
id,
prop: "lorem ipsum dolor sit atmet",
prop2: 123456
}
}
@alestrunda
alestrunda / performance-blob.js
Last active January 10, 2023 12:40
Performance Testing - Blob
// create huge strings, then merge them together in a blob and download it as a file
// how much memory is available depends on the system, one "out" variable holds about 500mb, remove some if it crashes
// creates 1.93gb file
console.log(window.performance.memory)
let out1 = "";
for(let i=0;i<10_000_000;i++) {
out1 += i + 'asdafsasf as fasf asf asf asf asf as fa f';
}
let out2 = "";
for(let i=0;i<10_000_000;i++) {
@alestrunda
alestrunda / resizeFocuser.js
Created April 28, 2022 07:44
Fix screen scroll position to a selected element on window resize
/*
Focus screen scroll position on a selected element when window resizes.
Have you ever developed a responsive design of an element but when you're resizing the window the element is jumping
up and down because the content around resizes too? This simple function will fix the top of the screen to the top
of the selected element when the window resizes. Just define the function in dev console and then run it.
Usage: resizeFocuser('div.element-to-focus-on');
*/
function resizeFocuser(selector, offset = 0) {
@alestrunda
alestrunda / getCommitsSince.js
Last active March 19, 2021 19:49
Get commits from all your GitHub repos since particular date
/*
Description: gets commits from all your GitHub repos since particular date - public and private repos (you will need access token for that)
Requirements:
- set your GitHub username
- get your GitHub access token
- make sure axios package is installed
Example:
//commits that are not older than 1 month (github api returns this activity from up to 90 days ago)
@alestrunda
alestrunda / getReposCnt.js
Created March 7, 2021 21:09
Get GitHub repos count
/*
Description: gets total count of your GitHub repos - public and private (you will need access token for that)
Requirements:
- get your GitHub access token
- make sure axios package is installed
Example: await getReposCnt()
*/
### Keybase proof
I hereby claim:
* I am alestrunda on github.
* I am alestrunda1 (https://keybase.io/alestrunda1) on keybase.
* I have a public key ASBb8DXXcM5JBwp7WEuVW1fl6gqlwNSFk67o1sHASMnR0Qo
To claim this, I am signing this object: