Skip to content

Instantly share code, notes, and snippets.

View munkacsitomi's full-sized avatar

Tamás Munkácsi munkacsitomi

  • Amsterdam, Netherlands
View GitHub Profile
@munkacsitomi
munkacsitomi / sticky-footer.css
Created August 28, 2019 13:06
Sticky footer solution with flexbox
@munkacsitomi
munkacsitomi / responsive-font.scss
Created August 23, 2019 21:49
Responsive font
@mixin responsive-font($responsive, $min, $max: false, $fallback: false) {
$responsive-unitless: $responsive / ($responsive - $responsive + 1);
$dimension: if(unit($responsive) == 'vh', 'height', 'width');
$min-breakpoint: $min / $responsive-unitless * 100;
@media (max-#{$dimension}: #{$min-breakpoint}) {
font-size: $min;
}
@if $max {
@munkacsitomi
munkacsitomi / timeout-async-await.js
Last active July 26, 2019 11:14
Example how to create a timer with promises
const wait = async (time) => {
return new Promise((resolve) => {
setTimeout(resolve, time);
});
}
const waitInMs = 1000;
let isLoading = true;
let value = 1;
console.log(`value in the first iteration: ${value}`);
@munkacsitomi
munkacsitomi / local-storage.js
Created June 19, 2019 09:02
How to use data from local storage
// Instead of converting string to boolean
const isRetention = localStorage.getItem('is_retention') === 'true';
// Parsing the JSON is better solution
const isRetention = JSON.parse(localStorage.getItem('is_retention'));
// Or create a helper function to parse the item
const getLocalStorageItem = item => JSON.parse(localStorage.getItem(item));
const isRetention = getLocalStorageItem('is_retention');
@munkacsitomi
munkacsitomi / armd.js
Created June 12, 2019 10:51
Adding, Removing, Modifying, Deleting elements with ES6
// A
const newUser = {
id: 4,
name: "Denomer Crazy",
username: "crazy.1",
email: "[email protected]",
phone: "",
website: "crazy.app",
password: "crazed_checker"
};
@munkacsitomi
munkacsitomi / list-item.html
Created May 29, 2019 08:54
Replace default bullets in a list to an img with optional vertical center alignment
<ul class="my-list">
<li class="my-list__list-item">First item</li>
<li class="my-list__list-item">Second item</li>
<li class="my-list__list-item my-list__list-item--center">Third item</li>
</ul>
@munkacsitomi
munkacsitomi / loadScript.js
Last active September 11, 2020 12:41
Control the order of the script loads
var loadScript = (src, callback) => {
var script = document.createElement('script');
script.src = src;
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = callback;
}
(function() {
loadScript('firstScript.js', function() {
console.log('First script loaded!');
function makeRobot(name, job) {
return {
name: name,
job: job,
introduce: function() {
console.log(`Hi! I'm ${this.name}. My job is ${this.job}.`);
},
};
}
@munkacsitomi
munkacsitomi / brew-node.txt
Last active April 2, 2019 11:45
How to change node versions wit Homebrew
$ brew search node
$ brew install node
$ brew install node@8
$ brew unlink node@8
$ brew link --force --overwrite node@8
$ node --version
@munkacsitomi
munkacsitomi / clone-objects.js
Last active March 13, 2019 13:36
Different ways to clone objects in Javascript
// 1: Deep copy using iteration
const iterationCopy = (src) => {
let target = {};
for (let prop in src) {
if (src.hasOwnProperty(prop)) {
target[prop] = src[prop];
}
}
return target;
}