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
}
@taniarascia
taniarascia / index.html
Last active Sep 23, 2021
HTML Skeleton file
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<meta name="author" content="">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
@taniarascia
taniarascia / nav.html
Last active Aug 20, 2021
Responsive Dropdown Navigation Bar
View nav.html
<section class="navigation">
<div class="nav-container">
<div class="brand">
<a href="#!">Logo</a>
</div>
<nav>
<div class="nav-mobile">
<a id="nav-toggle" href="#!"><span></span></a>
</div>
<ul class="nav-list">
@taniarascia
taniarascia / functions.php
Last active Aug 4, 2021
Inlcuding custom fields and uploads in a WordPress post
View functions.php
<?php
function create_post_your_post() {
register_post_type( 'your_post',
array(
'labels' => array(
'name' => __( 'Your Post' ),
),
'public' => true,
'hierarchical' => true,
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
@taniarascia
taniarascia / memory-0.1.js
Last active Jun 30, 2021
Memory Game Tutorial
View memory-0.1.js
const cardsArray = [ /* ... */ ];
const game = document.getElementById('game');
const grid = document.createElement('section');
grid.setAttribute('class', 'grid');
game.appendChild(grid);
cardsArray.forEach(item => {
const card = document.createElement('div');
card.classList.add('card');
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 May 31, 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.php
Created Oct 18, 2015
Start Wordpress Tutorial
View index.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
View disassembly
000000 121a JP 0x21a
000002 434f SNE V3, 0x4f
000004 4e4e SNE Ve, 0x4e
000006 4543 SNE V5, 0x43
000008 5434 DW 0x5434
00000a 2062 CALL 0x62
00000c 7920 ADD V9, 0x20
00000e 4461 SNE V4, 0x61
000010 7669 ADD V6, 0x69
000012 6420 LD V4, 0x20