Skip to content

Instantly share code, notes, and snippets.

View anacampesan's full-sized avatar
🏡
WFH

Ana Campesan anacampesan

🏡
WFH
View GitHub Profile
@anacampesan
anacampesan / react-table-dnd-reordering.js
Created March 30, 2020 19:38
Column Drag & Drop Reordering - react-table
// In your component, add this var and functions:
let columnBeingDragged = null;
const onDragStart = e => {
columnBeingDragged = e.target.dataset.columnIndex;
};
const onDrop = e => {
e.preventDefault();
@anacampesan
anacampesan / delete_branches.sh
Created July 31, 2019 19:45
Delete all branches but master
git branch -D $(git branch | grep -v master)
@anacampesan
anacampesan / threejs-snippets.js
Last active July 26, 2019 16:24
Three JS Snippets
// Scene
const container = document.querySelector('#scene-container');
var scene = new THREE.Scene();
scene.background = new THREE.Color('blue');
//scene.add(stuff)
// Renderer
const renderer = new THREE.WebGLRenderer({alpha: true});
renderer.setSize(container.clientWidth, container.clientHeight);
@anacampesan
anacampesan / CarouselComponent.jsx
Created June 25, 2019 20:38
Carousel component implemented in React
import React from 'react';
import PropTypes from 'prop-types';
import CarouselButton from './CarouselButton';
const Carousel = ({ children }) => {
const scroll = direction => {
const carousel = document.querySelector('#carousel');
const step = 30; // scrolling by 30px
carousel.scrollTop =
@anacampesan
anacampesan / docker.md
Last active May 15, 2019 21:35
Creating Docker containers

docker build -t name -t TAG builds image from dockerfile docker run -v pwd/app:/app -p 3000:3000 -it -d ana/name docker ps docker exec -it /bin/bash

@anacampesan
anacampesan / destructuring_array_of_objects.js
Last active June 28, 2019 14:17
JS - Destructuring Array of Objects
let a = [{grape: 1}, {orange: 2}, {peach: 3}];
let b = {};
// turn b into {grape: 1, orange:2, peach: 3}
a.forEach((el, i) => {
b[Object.keys(a[i])] = el[Object.keys(el)[0]]
})
// using object destructuring syntax
let [{grape}, {orange}, {peach}] = a;
function solution(A) {
// write your code in JavaScript (Node.js 8.9.4)
let sortedA = A.sort();
for (let i = 0; i < sortedA.length; i++) {
console.log(sortedA.indexOf(sortedA[i] + 1))
if (sortedA.indexOf(sortedA[i] + 1) === -1) {
return sortedA[i] + 1;
}
}
@anacampesan
anacampesan / webpack.config.js
Created March 16, 2019 21:43
Basic webpack config for JS and SASS
var path = require("path");
module.exports = {
entry: "./main.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
publicPath: "/dist"
},
module: {
function elementIsVisible(el) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elTop = $(el).offset().top;
var elBottom = elTop + $(el).height();
return ((elBottom - $(el).height() <= docViewBottom)
&& (elTop + $(el).height() >= docViewTop));
}
.myDiv {
border: 2px solid beige;
border-image: linear-gradient(to top, beige 95%, rgba(0,0,0,0) 95%); /* Change direction, color and height accordingly */
border-image-slice: 1;
}