Skip to content

Instantly share code, notes, and snippets.

View cristinafsanz's full-sized avatar

Cristina Fernández Sanz cristinafsanz

View GitHub Profile
@cristinafsanz
cristinafsanz / xon-GridCanvas.vue
Created April 23, 2021 08:13 — forked from xon52/xon-GridCanvas.vue
Medium - Flexible Canvas Grid (without blurred lines)
<template>
<canvas class="gridCanvas"
:width="width"
:height="height"
></canvas>
</template>
<script>
export default {
name: 'xon-GridCanvas',
@cristinafsanz
cristinafsanz / for_in.js
Created December 1, 2020 09:26 — forked from chathurawidanage/for_in.js
Iterating Over Object Entries in JS using for...in | Performance Comparison [https://gists.cwidanage.com/2018/06/how-to-iterate-over-object-entries-in.html]
let obj = {
key1: "value1",
key2: "value2",
key3: "value3"
}
for (const key in obj) {
let value = obj[key];
//optional check for properties from prototype chain
@cristinafsanz
cristinafsanz / spread-operator.js
Created November 12, 2020 11:14 — forked from rubnvp/spread-operator.js
JavaScript spread operator to conditionally add keys to objects or elements to arrays
const user = {
name: 'John',
...isAdmin && {adminGroup: 'super-admin'},
};
const options = [
'fruits',
...hasFlowers ? ['flowers'] : [],
];
@cristinafsanz
cristinafsanz / async-foreach.js
Created February 20, 2020 13:53 — forked from atinux/async-foreach.js
JavaScript: async/await with forEach()
const waitFor = (ms) => new Promise(r => setTimeout(r, ms))
const asyncForEach = async (array, callback) => {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array)
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50)
export default function() {
document.querySelectorAll('.js-share-facebook-link').forEach(function(el){
el.addEventListener('click', function(e){
var href = e.target.href;
e.preventDefault();
window.open(href, "Facebook", "toolbar=no,location=0,status=no,menubar=no,scrollbars=yes,width=600,height=400,resizable=1");
})
});
@cristinafsanz
cristinafsanz / command.txt
Created October 24, 2019 16:29 — forked from fbn4sc/command.txt
Delete all branches except master and develop.
git branch | grep -v "master\|develop" | xargs git branch -D
@cristinafsanz
cristinafsanz / csrf-token-nuxt.js
Last active August 26, 2021 15:43 — forked from mbrochh/gist:3338679
Get CSRF Token from cookie for AJAX calls against Django views
/**
* Get Csrf token from document.cookie
*/
getCsrfToken () {
if (!process.client) {
return null
}
const regex = /csrftoken=(.[^;]*)/ig
const match = regex.exec(document.cookie)
return match[1]
@cristinafsanz
cristinafsanz / package.json
Created June 29, 2019 10:55 — forked from corysimmons/package.json
babel, sass, npm-run-all
{
"devDependencies": {
"babel-cli": "^6.10.1",
"babel-preset-es2015": "^6.9.0",
"babel-preset-stage-0": "^6.5.0",
"node-sass": "^3.8.0",
"npm-run-all": "^2.2.2"
},
"babel": {
"presets": [
@cristinafsanz
cristinafsanz / .eslintrc
Created June 29, 2019 10:33 — forked from jamiemagique/.eslintrc
Pre commit JS and SCSS fixing via Husky, Lint-Staged and StyleLint with AirBnB linting.
{
"parser": "babel-eslint",
"env": {
"browser": true,
"node": true
},
"extends": "airbnb",
"rules": {
"no-console":0,
"nomen": 0
@cristinafsanz
cristinafsanz / sticky-footer-no-vh.css
Last active August 23, 2019 10:15 — forked from palicko/sticky-footer.css
First solution: Sticky footer with flexbox (works in IE11) Second solution to work also in Edge previous versions (example Edge 44), with 100vh there were a lot of space after footer: https://developer.mozilla.org/en-US/docs/Web/CSS/Layout_cookbook/