| enska | ísl |
|---|---|
| container | innihaldari |
| wrapper | umvafningur |
| animation | kvikun |
| transform | ummynda |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| const TodoApp = () => { | |
| const [todos, setTodos] = useState([]); | |
| const [inputValue, setInputValue] = useState(''); | |
| const addTodo = () => { | |
| if (inputValue !== '') { | |
| const newTodo = { | |
| id: Date.now(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Honestly there must be an easier way to do this, but im a noob | |
| PSAUX="$(ps)" | |
| while IFS= read -r line; do | |
| if [[ $line == *"gatsby develop"* ]]; then | |
| id=$(echo $line | cut -d " " -f 1) | |
| kill -9 $id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * from https://stackoverflow.com/a/49434653 | |
| */ | |
| export const boxMullerTransformedRand = (): number => { | |
| let u = 0, v = 0 | |
| while (u === 0) u = Math.random() //Converting [0,1) to (0,1) | |
| while (v === 0) v = Math.random() | |
| let num = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v) | |
| num = num / 10.0 + 0.5 // Translate to 0 -> 1 | |
| if (num > 1 || num < 0) return boxMullerTransformedRand() // resample between 0 and 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const logger = (label, printer = null) => (...args) => { | |
| (printer || console.log)(`[${label}]`, ...args) | |
| const [first] = args | |
| return first | |
| } | |
| export default logger | |
| // example usage: | |
| const log = logger('user clicked button') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const strHash = str => { | |
| let hash = 0 | |
| for (let i = 0; i < str.length; i++) { | |
| let charCode = str.charCodeAt(i) | |
| hash = (hash << 5) - hash + charCode | |
| hash = hash & hash | |
| } | |
| return hash | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Array.prototype.forEach.call(document.forms, f => { console.log('[' + f.method + '] ' + f.action); console.table(Array.prototype.map.call(f.elements, el => { return {name: el.name, nodeName: el.nodeName } }))}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Class Yoyo | |
| { | |
| public static function objectToArray($obj) { | |
| if (is_object($obj)) { | |
| $reflect = new \ReflectionClass($obj); | |
| $props = $reflect->getProperties(); | |
| $d = array(); | |
| foreach ($props as $prop) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var els = document.querySelectorAll('h1, h2, h3, h4, h5, h6, a, p, div'); | |
| function transform() { | |
| Array.prototype.forEach.call(els, function(p) { | |
| p.style.transform = 'translateY(' + (Math.random() - 0.5) + 'px)'; | |
| }); | |
| requestAnimationFrame(function() { | |
| transform(); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function islCompare() { | |
| var order = '0123456789aAáÁbBcCdDeEéÉfFgGhHiIíÍjJkKlLmMnNoOóÓpPqQrRsStTuUúÚvVwWxXyYýÝzZþÞæÆöÖ'; | |
| function charOrder(a) { | |
| var ix = order.indexOf(a); | |
| return ix === -1 ? a.codePointAt() + order.length : ix; | |
| } | |
| return function(a, b) { | |
| for (var i = 0; i < Math.min(a.length, b.length); i++) { |
NewerOlder