TL;DR: If you want to see me perform a spoken word poem about JavaScript in front of 1000 people (and on video), please ⭐ star this gist. If you're on mobile, you'll need to request desktop site.
| import React from 'react'; | |
| import { connect } from 'formik'; | |
| class ErrorFocus extends React.Component { | |
| componentDidUpdate(prevProps) { | |
| const { isSubmitting, isValidating, errors } = prevProps.formik; | |
| const keys = Object.keys(errors); | |
| if (keys.length > 0 && isSubmitting && !isValidating) { | |
| const selector = `[id="${keys[0]}"]`; | |
| const errorElement = document.querySelector(selector); |
| <?php | |
| $currency_symbols = array( | |
| 'AED' => 'د.إ', // ? | |
| 'AFN' => 'Af', | |
| 'ALL' => 'Lek', | |
| 'AMD' => 'դ', | |
| 'ANG' => 'ƒ', | |
| 'AOA' => 'Kz', // ? | |
| 'ARS' => '$', | |
| 'AUD' => '$', |
| // why do this? clip-path accepts a `url` reference to an svg element, right? | |
| // the difference is that anything defined as a `basic-shape` can be animated: | |
| // https://developer.mozilla.org/en-US/docs/Web/CSS/clip-path | |
| const input = `121.151,20.761 170.165,55.885 200.872,3.816 231.145,55.884 280.592,20.762 286.854,80.687 346.526,68.666 | |
| 327.657,126.005 387.276,139.247 346.502,184 395.796,220.302 340.127,244.647 370.611,297.814 309.636,297.457 316.076,358.381 | |
| 260.303,333.3 241.622,391.529 200.655,345.979 160.121,391.53 141.008,333.302 85.666,358.381 91.673,297.456 31.131,297.813 | |
| 61.183,244.647 5.947,220.302 54.81,184 14.466,139.248 73.652,126.004 55.216,68.667 114.457,80.688 ` | |
| const viewBoxScale = 4 |
| <?php | |
| /** | |
| * Add rest api endpoint for category listing | |
| */ | |
| /** | |
| * Class Category_List_Rest | |
| */ | |
| class Category_List_Rest extends WP_REST_Controller { | |
| /** |
FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.
| <!-- Specifying multiple formats --> | |
| <input type="file" accept=".csv, .txt" /> | |
| <!-- For CSV --> | |
| <input type="file" accept=".csv" /> | |
| <!-- For Excel 97-2003 --> | |
| <input type="file" accept="application/vnd.ms-excel" /> | |
| <!-- For Excel 2007+ --> |
| // Implementation in ES6 | |
| function pagination(c, m) { | |
| var current = c, | |
| last = m, | |
| delta = 2, | |
| left = current - delta, | |
| right = current + delta + 1, | |
| range = [], | |
| rangeWithDots = [], | |
| l; |