Skip to content

Instantly share code, notes, and snippets.

View AndreaBarghigiani's full-sized avatar

Andrea Barghigiani AndreaBarghigiani

View GitHub Profile
@sebmarkbage
sebmarkbage / The Rules.md
Last active April 22, 2024 04:41
The Rules of React

The Rules of React

All libraries have subtle rules that you have to follow for them to work well. Often these are implied and undocumented rules that you have to learn as you go. This is an attempt to document the rules of React renders. Ideally a type system could enforce it.

What Functions Are "Pure"?

A number of methods in React are assumed to be "pure".

On classes that's the constructor, getDerivedStateFromProps, shouldComponentUpdate and render.

@actual-saurabh
actual-saurabh / llms-remove-notifications.php
Last active September 5, 2019 08:49
Remove frontend notifications from LifterLMS
<?php // Do not copy this line
// Copy from under this line and paste into your child theme's functions.php
add_action( 'init', 'llms_turn_off_notifications', 10, 999 );
add_action( 'wp_enqueue_scripts', 'llms_dequeue_notification_script', 10, 999 );
if ( ! function_exists( 'llms_turn_off_notifications' ) ){
function llms_turn_off_notifications(){

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.

@jtsternberg
jtsternberg / cmb2-number-field.php
Last active February 28, 2022 03:30
CMB2 Number Field
<?php
$cmb->add_field( array(
'name' => __( 'Postive numbers', 'theme-domain' ),
'desc' => __( 'Numbers only', 'msft-newscenter' ),
'id' => $prefix . 'number',
'type' => 'text',
'attributes' => array(
'type' => 'number',
'pattern' => '\d*',
@gaspanik
gaspanik / bs-config.js
Created June 3, 2014 09:08
Browser-Sync Config for WordPress Theme Dev.
/*
|--------------------------------------------------------------------------
| Browser-sync config file
|--------------------------------------------------------------------------
|
| Please report any issues you encounter:
| https://github.com/shakyShane/browser-sync/issues
|
| For up-to-date information about the options:
| https://github.com/shakyShane/browser-sync/wiki/Working-with-a-Config-File
@lodestone
lodestone / 5-reasons-to-avoid-atom.markdown
Created February 27, 2014 20:00
Five Reasons You Should Avoid Github's Atom Editor

5 Reasons You Should Avoid Github's Atom Editor

1. There's a Big Hoopla

It must be a passing thing. Just trendy teenagers hopping on the bandwagon. Another fad from an industry that is addicted to it. It must be these things, despite Github's six years of work on it before release. It must be worth avoiding despite the fact that obvious thought, time, and love has been put into the project.

2. It doesn't do X!!!

Yeah, it doesn't do X. It does Y and Z really well, but because it doesn't do X yet it must be eschewed. End of story.

@studiopress
studiopress / genesis-read-more.php
Last active August 10, 2020 09:51
Genesis post excerpts.
<?php
//* Do NOT include the opening php tag shown above. Copy the code shown below.
//* Modify the Genesis content limit read more link
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '... <a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>';
}
@jareware
jareware / SCSS.md
Last active April 23, 2024 22:13
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso