Skip to content

Instantly share code, notes, and snippets.

View Uvacoder's full-sized avatar

uvacoder Uvacoder

View GitHub Profile
@Uvacoder
Uvacoder / limit-map-loop.js
Created October 18, 2022 16:06 — forked from whoisryosuke/limit-map-loop.js
Javascript - Limit a `.map()` loop to a certain number using `.slice()`- via: https://stackoverflow.com/questions/42374873/limit-items-in-a-map-loop
var film = this.props.data.slice(0, 5).map((item) => {
return <FilmItem key={item.id} film={item} />
});
return film;
@Uvacoder
Uvacoder / 55-bytes-of-css.md
Created October 2, 2022 01:28 — forked from JoeyBurzynski/55-bytes-of-css.md
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@Uvacoder
Uvacoder / notion2blog.js
Created September 30, 2022 08:27 — forked from mayneyao/notion2blog.js
Notion.so > Personal Blog | custom domain + disqus comment
const MY_DOMAIN = "agodrich.com"
const START_PAGE = "https://www.notion.so/gatsby-starter-notion-2c5e3d685aa341088d4cd8daca52fcc2"
const DISQUS_SHORTNAME = "agodrich"
addEventListener('fetch', event => {
event.respondWith(fetchAndApply(event.request))
})
const corsHeaders = {
"Access-Control-Allow-Origin": "*",
@Uvacoder
Uvacoder / esm-package.md
Created August 25, 2022 15:45 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@Uvacoder
Uvacoder / writing-eslint-rule.md
Created August 25, 2022 15:43 — forked from sindresorhus/writing-eslint-rule.md
Gettings started writing a ESLint rule

Gettings started writing a ESLint rule

First, take a look at the ESLint rule documentation. Just skim it for now. It's very long and boring. You can come back to it later.

ESLint rules works on the AST (Abstract Syntax Tree) representation of the code. In short, this is a tree structure that describes the code in a very verbose form. ESLint walks this tree and rules can subscribe to be notified when it hits a specific node type, like a Literal type, which could be the "hello" part of const welcome = "hello";.

Go ahead and play around with some code in AST Explorer (Make sure the parser is espree). It's a great tool!

Here are some good articles on the subject (ignore the scaffolding parts):

@Uvacoder
Uvacoder / hex-to-rgb.js
Created August 22, 2022 11:42 — forked from magicznyleszek/hex-to-rgb.js
Hex to RGB
function hexToRgb(hex) {
// Expand shorthand form ("#FFF") to full form ("#FFFFF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
// return hex values
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
@Uvacoder
Uvacoder / css-selectors.md
Created August 22, 2022 11:41 — forked from magicznyleszek/css-selectors.md
CSS Selectors Cheatsheet

CSS Selectors Cheatsheet

Hi! If you see an error or something is missing (like :focus-within for few years :P) please let me know ❤️

Element selectors

Element -- selects all h2 elements on the page

h2 {
@Uvacoder
Uvacoder / github-actions-notes.md
Created May 11, 2022 12:26 — forked from br3ndonland/github-actions-notes.md
Getting the Gist of GitHub Actions
@Uvacoder
Uvacoder / benford_counter.rb
Created February 4, 2022 12:58 — forked from brycethornton/benford_counter.rb
Benford Counter
class BenfordCounter
def initialize
@num_count = {}
# Set all values to zero
(1..9).each {|num| @num_count[num] = 0 }
@total_records = 0
@min_value = 9999999999
@max_value = 0
@Uvacoder
Uvacoder / data.csv
Created January 3, 2022 01:51 — forked from agung037/data.csv
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
1000001-x 86 56 64 95
1000002-y 81 67 63 53
1000003-x 45 46 97 67
1000004-x 75 68 95 72
1000005-y 89 54 72 66
1000006-z 66 70 84 90
1000007-x 68 76 84 89
1000008-z 97 62 56 53
1000009-y 76 48 90 51
1000010-y 62 67 92 70