Skip to content

Instantly share code, notes, and snippets.

@taniarascia
taniarascia / isOdious.js
Created Oct 13, 2021
Check if a number is odious
View isOdious.js
function isOdious(x) {
if (x < 0) throw new Error('Value must be positive!')
const binaryExpansion = x.toString(2)
const count = Array.from(binaryExpansion).reduce((acc, val) => (val == 1 ? acc + 1 : acc), 0)
return count % 2 === 1
}
View git.md

Git

Git command reference.

Upload all files in a local directory to a new Git repository

If you have a project on your computer and you just created an empty Git repository in GitHub, use these commands to upload everything to Git.

cd your-directory
View react.md

React Architecture: How to Structure and Organize a React Application

There is no consensus on the right way to organize a React application. React gives you a lot of freedom, but with that freedom comes the responsibility of deciding on your own architecture. Often the case is that whoever sets up the application in the beginning throws almost everything in a components folder, or maybe components and containers if they used Redux, but I propose there's a better way. I like to be deliberate about how I organize my applications so they're easy to use, understand, and extend.

I'm going to show you what I consider to be an intuitive and scalable system for large-scale production React applications. The main concept I think is important is to make the architecture focused on feature as opposed to type, organizing only shared components on a global level and modularized all the other related entities together in the localized view.

Tech assumptions

Since this article will be opinionated,

@taniarascia
taniarascia / auth.md
Last active Nov 8, 2021
JavaScript Authentication & Authorization Book/Course
View auth.md

Authentication in Real-World Web Apps with JavaScript

Outline of ideas, concepts to cover, potential projects to write.

Setup Idea

  • Book with a video for each chapter.

Prerequisites/Overview

@taniarascia
taniarascia / index.css
Created Mar 6, 2020
React Redux Application
View index.css
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
p {
font-size: 1.1rem;
}
@taniarascia
taniarascia / fakeNotes.json
Last active Sep 28, 2019
fake initial state test
View fakeNotes.json
[
{
"id":"shfksjh32hrkwefhkj3h",
"text":"# Example default note\n\n- [Laconia](https://laconia.dev)\n- [Chip8.js](https://github.com/taniarascia/chip8",
"created":"",
"lastUpdated":""
},
{
"id":"893hfehfkjshkj233",
"text":"# Another something else\n\nEveryone loves notes",
View async.js
method1 = async () => {
const things = await getThings()
for (let thing of things) {
const stuff = await getStuffFromThing(thing)
console.log(stuff) // works
}
}
method2 = async () => {
View new-moon.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Alpha Component</key>
<real>1</real>
<key>Blue Component</key>
<real>0.77254903316497803</real>
View Roadmap.md

Roadmap of Web Development

Getting Started

Operating System

What operating system your computer runs on.

  • Mac, Windows, Linux
View demorgan.js
(this == that || these == those) is (this != that && these != those)
!(a && b) == (!a || !b)
!(a || b) == (!a && !b)