Skip to content

Instantly share code, notes, and snippets.

@nodkz
nodkz / .babelrc.js
Last active March 25, 2024 16:16
Babel 7.0 with .babelrc.js DEPRECATED! This config was created when babel 7 was in beta
/* eslint-disable prefer-template */
const path = require('path');
const aliases = require('./aliases');
// ///////////////////////////////////////////////////////////////
// ////////////////// PLUGINS ////////////////////////////////
// ///////////////////////////////////////////////////////////////
const commonPlugins = [

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.

@jbroadway
jbroadway / Slimdown.md
Last active February 5, 2024 10:43
Slimdown - A simple regex-based Markdown parser.
@renehamburger
renehamburger / slimdown.js
Last active September 4, 2023 07:55
slimdown.js
'use strict';
/**
* Javascript version of https://gist.github.com/jbroadway/2836900
*
* Slimdown - A very basic regex-based Markdown parser. Supports the
* following elements (and can be extended via Slimdown::add_rule()):
*
* - Headers
* - Links
@jeanbenitez
jeanbenitez / list-to-matrix.ts
Created May 7, 2019 15:25
Simple array to matrix algorithm with Typescript
/**
* Convert simple array into two-dimensional array (matrix)
*
* @param list The array
* @param width The num of elements per sub-array
* @return the new matrix
*/
export const listToMatrix = <T>(list: T[], width: number): T[][] => {
const matrix = [];
@hitautodestruct
hitautodestruct / readme.md
Last active September 26, 2022 11:25 — forked from anonymous/gist:4344870
Generate a custom structure for Wordpress menus.

This gist is for showing an example of a custom wordpress menu.

If you want to get more from the menu item simply have a look at the $item object. i.e:

// Will return a large object with lots of props like title, url, description, id etc.
var_dump( $item );

This code works on Wordpress 4.1.1 as of 31st of March 2015

@scribu
scribu / taxonomy-columns.php
Created July 12, 2012 15:35
'show_admin_column' => true
<?php
add_action( 'registered_taxonomy', array( 'APP_Tax_Admin_Column', 'register_column' ), 10, 3 );
/**
* Generates a column with the associated terms,
* for any taxonomy with 'show_admin_column' => true
*/
class APP_Tax_Admin_Column {
@mateuszsokola
mateuszsokola / _PureFunctions.md
Last active August 9, 2021 14:36
Pure Functions

Pure functions

A pure function for given the same input will always return the same output and evaluation of this function will not cause any side effects.

Advantages of using pure functions:

  • easy to test, as they always return the same value,
  • easy to debug, as they shouldn't cause any race conditions and circular dependencies,
  • simple and independent, as they don't cause any side effects (it makes design clean),
  • easy to scale application up, as they shouldn't rely on machine state.
@rexxars
rexxars / jsondump.jsx
Last active December 19, 2019 05:22
React JSON dump component
import React from 'react';
class JsonDump extends React.Component {
static propTypes = {
children: React.PropTypes.any
}
render() {
return <pre>{JSON.stringify(this.props.children, null, 4)}</pre>
}
/**
* Helper class for controlling all aspects of a view.
*
* Supported methods (automatically hooked):
* - init() - for registering post types, taxonomies, rewrite rules etc.
* - parse_query() - for correcting query flags
* - pre_get_posts() - for altering the query, without affecting the query flags
* - posts_search(), posts_clauses(), posts_request() - for direct SQL manipulation
* - the_posts() - for various other manipulations
* - template_redirect() - for enqueuing scripts etc.