Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
darrenjaworski / createstore.js
Created August 18, 2018 17:11
redux createstore
// basic instance of store in redux
const createStore = reducer => {
let state;
let listeners = [];
const getState = () => state;
const dispatch = action => {
state = reducer(state, action);
listeners.forEach(listener => listener());
@darrenjaworski
darrenjaworski / cra-comp-library.md
Last active August 10, 2018 02:55
Convert create react app to a component library...

Use CRA to get you going.

$ npx create-react-app component-library

You're going to want styleguidist. Follow the instructions here.

Add .babelrc file to the root of your library.

@darrenjaworski
darrenjaworski / accessible.md
Last active April 4, 2018 13:08
web accessibility - checklist

Adopted from (webaim)[https://webaim.org/intro/].

More good resources: (google accessibility)[https://developers.google.com/web/fundamentals/accessibility/], (w3)[https://www.w3.org/WAI/intro/accessibility.php]

  • every img should have alt text that describes what is in the image
  • keyboard navigation within the page, (tab and arrow keys)
  • in a form, every element has a label, and describes what appropriately the form element is
  • ensure every form element within a form can be navigated to
  • caption and/or transcripts for media (audio/video)
  • every link should make sense with the link text, avoid "submit, click here" etc
@darrenjaworski
darrenjaworski / index.html
Last active March 16, 2018 03:56
materializecss modals
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.100.2/css/materialize.min.css">
</head>
@darrenjaworski
darrenjaworski / ack.js
Created April 17, 2017 22:23
Ackermann Function - JS
function ackermann(m, n) {
var ans;
if (m === 0) {
ans = n + 1;
} else if (n === 0) {
ans = ackermann(m - 1, 1);
} else {
ans = ackermann(m - 1, ackermann(m, n - 1));
}
return ans;
@darrenjaworski
darrenjaworski / index.html
Created November 14, 2016 20:02
embed test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="http://oklahoma-bookdirect.com/widgets/search_widget.js.php?id=334" type="text/javascript" language="javascript"></script>
</body>
</html>
@darrenjaworski
darrenjaworski / .DS_Store
Last active October 26, 2016 00:51
Nationwide Farmers Markets
@darrenjaworski
darrenjaworski / wp-config.php
Created August 8, 2016 16:22
wp config database conditional
<?php
// ... An alternative to a multisite config while using the same codebase.
// ... In my use case: parent and child theme with two different domains. Multisite not wanted. (although it would make life easier)
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
$domain_one = preg_match( '/domainone\.com/', $_SERVER['SERVER_NAME'] );
$domain_two = preg_match('/domaintwo\.com/', $_SERVER['SERVER_NAME'] );
if ( $domain_one ) {
define('DB_NAME', 'database_one');
@darrenjaworski
darrenjaworski / index.html
Last active February 15, 2017 13:18
d3 fitextent and responsive projection
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
body {
margin: 0;
}
svg {