Skip to content

Instantly share code, notes, and snippets.

@Dodsaren
Dodsaren / useJimbo.js
Last active August 21, 2020 10:26
Example of "global" hook utilizing react context
import React, { useContext, useState } from 'react';
const initialState = 'Jimbo';
const JimboContext = React.createContext(initialState, () => {});
export const JimboProvider = ({ children }) => {
const [state, setState] = useState(initialState);
return (
<JimboContext.Provider value={[state, setState]}>
{children}
docker run -d -p 8082:80 --mount type=bind,source="$(pwd)/htdocs",target=/var/www/html php:apache
1. If the Docker image php:apache is not present in your machine's local Docker registry, it will be downloaded from Docker hub.
2. It creates a new container based on the image php:apache.
3. It maps port 80 from the container to port 8082 on your host machine.
4. It mounts the directory htdocs/ from your host machine to /var/www/html in the container.
https://nelkinda.com/blog/apache-php-in-docker/
Varje gång man kommer hem till gamla söder
och ser ut från Mosebacke över stan
då går pumpen varm ja så det nästan glöder
det var här som man höll till när man var barn
Minns hur vackert ljusen spegla sig om natten
passa på att stanna till en liten stund
ser hur silvertärnor smeker saltsjöns vatten
medan färjan lägger till vid Gröna lund
git fetch origin pull/123/head:pr/123 && git checkout pr/123
git push -d <remote_name> <branch_name>
import { useState, useEffect } from 'react';
function useDebounce(value, delay) {
const [debouncedValue, setDebouncedValue] = useState(value);
useEffect(() => {
const handler = setTimeout(() => {
setDebouncedValue(value);
}, delay);
return () => {
@Dodsaren
Dodsaren / accordion.css
Created February 12, 2020 13:33
Css accordion solution
.accordion-content {
overflow: hidden;
max-height: 0;
transition: max-height 0.5s cubic-bezier(0, 1, 0, 1);
}
.accordion-content.open {
max-height: 1000px;
transition: max-height 1s ease-in-out;
}
@Dodsaren
Dodsaren / git.md
Last active April 15, 2020 13:22
git

Undo last commit:

Keep changes in staged

git reset --soft HEAD~1

Remove changes completely

git reset --hard HEAD~1

function isAnagram(w1, w2) {
if (w1.length !== w2.length) {
return false
}
const a1 = Array.from(w1).sort()
const a2 = Array.from(w2).sort()
for (let i = 0; i < a1.length; i++) {
if (a1[i] !== a2[i]) {
@Dodsaren
Dodsaren / deeplog.js
Created February 21, 2018 21:50
log objects in depth in node
console.log(JSON.stringify(data, null, 2));