diff --git a/source/_posts/c.md b/source/_posts/c.md index cbd23a5..aaa744c 100644 --- a/source/_posts/c.md +++ b/source/_posts/c.md @@ -9,6 +9,7 @@ intro: | C quick reference cheat sheet that provides basic syntax and methods. plugins: - copyCode + - runCode --- ## Getting Started @@ -58,7 +59,7 @@ int y = 6; int sum = x + y; // add variables to sum // declare multiple variables -int x = 5, y = 6, z = 50; +int a = 5, b = 6, c = 50; ``` ### Constants diff --git a/source/_posts/canvas.md b/source/_posts/canvas.md index 44bae10..15cc57a 100644 --- a/source/_posts/canvas.md +++ b/source/_posts/canvas.md @@ -10,6 +10,7 @@ intro: | This HTML Canvas quick reference cheat sheet lists the common HTML5 Canvas design tags in readable layout. plugins: - copyCode + - runCode --- ## Getting Started @@ -23,12 +24,7 @@ plugins: Canvas Example - + diff --git a/source/_posts/cpp.md b/source/_posts/cpp.md index 9c17778..2c01793 100644 --- a/source/_posts/cpp.md +++ b/source/_posts/cpp.md @@ -9,6 +9,7 @@ intro: | C++ quick reference cheat sheet that provides basic syntax and methods. plugins: - copyCode + - runCode --- ## Getting Started @@ -467,6 +468,7 @@ for(int i = 1; i > 0; i++) { ```cpp #include +#include int main() { diff --git a/source/_posts/css3.md b/source/_posts/css3.md index 9f70c4e..51236ad 100644 --- a/source/_posts/css3.md +++ b/source/_posts/css3.md @@ -12,6 +12,7 @@ intro: | This is a quick reference cheat sheet for CSS goodness, listing selector syntax, properties, units and other useful bits of information. plugins: - copyCode + - runCode --- ## Getting Started @@ -66,10 +67,14 @@ Overrides all previous styling rules. ### Selector ```css -h1 { } -#job-title { } -div.hero { } -div > p { } +h1 { +} +#job-title { +} +div.hero { +} +div > p { +} ``` See: [Selectors](#css-selectors) @@ -245,7 +250,10 @@ p:first-child { | `div,p` | All divs and paragraphs | | `#idname *` | All elements inside #idname | -See also: [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors) / [Class](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) / [ID](https://developer.mozilla.org/en-US/docs/Web/CSS/ID_selectors) / [Universal](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors) selectors +See also: [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors) / +[Class](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) / +[ID](https://developer.mozilla.org/en-US/docs/Web/CSS/ID_selectors) / +[Universal](https://developer.mozilla.org/en-US/docs/Web/CSS/Universal_selectors) selectors ### Combinators @@ -258,7 +266,9 @@ See also: [Type](https://developer.mozilla.org/en-US/docs/Web/CSS/Type_selectors | `div + p` | P tags immediately after div | | `div ~ p` | P tags preceded by div | -See also: [Adjacent](https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator) / [Sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator) / [Child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator) selectors +See also: [Adjacent](https://developer.mozilla.org/en-US/docs/Web/CSS/Adjacent_sibling_combinator) / +[Sibling](https://developer.mozilla.org/en-US/docs/Web/CSS/General_sibling_combinator) / +[Child](https://developer.mozilla.org/en-US/docs/Web/CSS/Child_combinator) selectors ### Attribute selectors @@ -345,12 +355,10 @@ See also: [Attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS | `letter-spacing:` | \ | | `line-height:` | \ | -| `font-weight:` | \ / bold / normal | -| `font-style:` | italic / normal | -| `text-decoration:` | underline / none | +| `font-weight:` | \ / bold / normal | | `font-style:` | italic / normal | | `text-decoration:` | underline / +none | -| `text-align:` | left / right
center / justify | -| `text-transform:` | capitalize / uppercase / lowercase | +| `text-align:` | left / right
center / justify | | `text-transform:` | capitalize / uppercase / lowercase | {.left-text} See also: [Font](https://developer.mozilla.org/en-US/docs/Web/CSS/font) @@ -453,14 +461,10 @@ color: currentcolor; /* keyword */ | ------------- | ------------- | | `background:` | _(Shorthand)_ | -| `background-color:` | See: [Colors](#css-colors) | -| `background-image:` | url(...) | -| `background-position:` | left/center/right
top/center/bottom | -| `background-size:` | cover X Y | -| `background-clip:` | border-box
padding-box
content-box | -| `background-repeat:` | no-repeat
repeat-x
repeat-y | -| `background-attachment:` | scroll/fixed/local | -{.left-text} +| `background-color:` | See: [Colors](#css-colors) | | `background-image:` | url(...) | | `background-position:` | +left/center/right
top/center/bottom | | `background-size:` | cover X Y | | `background-clip:` | +border-box
padding-box
content-box | | `background-repeat:` | no-repeat
repeat-x
repeat-y | | +`background-attachment:` | scroll/fixed/local | {.left-text} ### Shorthand {.secondary .col-span-2} @@ -475,16 +479,12 @@ color: currentcolor; /* keyword */ ```css {.wrap} background: url(img_man.jpg) no-repeat center; -background: url(img_flwr.gif) right bottom no-repeat, url(paper.gif) left top - repeat; +background: + url(img_flwr.gif) right bottom no-repeat, + url(paper.gif) left top repeat; background: rgb(2, 0, 36); -background: linear-gradient( - 90deg, - rgba(2, 0, 36, 1) 0%, - rgba(13, 232, 230, 1) 35%, - rgba(0, 212, 255, 1) 100% -); +background: linear-gradient(90deg, rgba(2, 0, 36, 1) 0%, rgba(13, 232, 230, 1) 35%, rgba(0, 212, 255, 1) 100%); ``` ## CSS The Box Model @@ -498,7 +498,10 @@ background: linear-gradient( } ``` -See also: [max-width](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) / [min-width](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) / [max-height](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) / [min-height](https://developer.mozilla.org/en-US/docs/Web/CSS/min-height) +See also: [max-width](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width) / +[min-width](https://developer.mozilla.org/en-US/docs/Web/CSS/min-width) / +[max-height](https://developer.mozilla.org/en-US/docs/Web/CSS/max-height) / +[min-height](https://developer.mozilla.org/en-US/docs/Web/CSS/min-height) ### Margin / Padding @@ -509,7 +512,8 @@ See also: [max-width](https://developer.mozilla.org/en-US/docs/Web/CSS/max-width } ``` -See also: [Margin](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) / [Padding](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) +See also: [Margin](https://developer.mozilla.org/en-US/docs/Web/CSS/margin) / +[Padding](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) ### Box-sizing @@ -764,8 +768,7 @@ A fixed-height top bar and a dynamic-height content area. } ``` -This creates columns that have different widths, but size accordingly according -to the circumstances. +This creates columns that have different widths, but size accordingly according to the circumstances. ### Vertical diff --git a/source/_posts/ejs.md b/source/_posts/ejs.md index 534a253..91dd1a9 100644 --- a/source/_posts/ejs.md +++ b/source/_posts/ejs.md @@ -12,6 +12,7 @@ intro: EJS(Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript. plugins: - copyCode + - runCode --- @@ -58,10 +59,11 @@ Pass EJS a template string and some data. ### Browser Support ```html - + ``` diff --git a/source/_posts/es6.md b/source/_posts/es6.md index 8139520..3b39a1f 100644 --- a/source/_posts/es6.md +++ b/source/_posts/es6.md @@ -11,6 +11,7 @@ intro: | A quick reference cheatsheet of what's new in JavaScript for ES2015, ES2016, ES2017, ES2018 and beyond plugins: - copyCode + - runCode --- ## Getting Started diff --git a/source/_posts/go.md b/source/_posts/go.md index 1ec8555..d350639 100644 --- a/source/_posts/go.md +++ b/source/_posts/go.md @@ -10,6 +10,7 @@ intro: | This cheat sheet provided basic syntax and methods to help you using [Go](https://go.dev/). plugins: - copyCode + - runCode --- ## Getting Started diff --git a/source/_posts/html.md b/source/_posts/html.md index 5d4d7bd..4a6fdd4 100644 --- a/source/_posts/html.md +++ b/source/_posts/html.md @@ -10,6 +10,7 @@ intro: | This HTML quick reference cheat sheet lists the common HTML and HTML5 tags in readable layout. plugins: - copyCode + - runCode --- ## Getting Started diff --git a/source/_posts/perl.md b/source/_posts/perl.md index 8d74397..8484d92 100644 --- a/source/_posts/perl.md +++ b/source/_posts/perl.md @@ -9,6 +9,7 @@ intro: | The perl quick reference cheat sheet that aims at providing help on writing basic syntax and methods. plugins: - copyCode + - runCode --- ## Getting Started @@ -36,7 +37,9 @@ $make install - Download either 32bit or 64bit version of installation. -- Run the downloaded file by double-clicking it in Windows Explorer. This brings up the Perl install wizard, which is really easy to use. Just accept the default settings, wait until the installation is finished, and you're ready to roll! +- Run the downloaded file by double-clicking it in Windows Explorer. This brings up the Perl install wizard, which is + really easy to use. Just accept the default settings, wait until the installation is finished, and you're ready to + roll! ### Macintosh Installation diff --git a/source/_posts/php.md b/source/_posts/php.md index a135035..6a8c890 100644 --- a/source/_posts/php.md +++ b/source/_posts/php.md @@ -10,6 +10,7 @@ intro: | This [PHP](https://www.php.net/manual/en/) cheat sheet provides a reference for quickly looking up the correct syntax for the code you use most frequently. plugins: - copyCode + - runCode --- ## Getting Started diff --git a/source/_posts/react.md b/source/_posts/react.md index c44a1c1..77c13e4 100644 --- a/source/_posts/react.md +++ b/source/_posts/react.md @@ -11,6 +11,7 @@ intro: | A React cheat sheet with the most important concepts, functions, methods, and more. A complete quick reference for beginners. plugins: - copyCode + - runCode --- ## Getting Started @@ -62,7 +63,7 @@ return ( ```javascript import React from "react"; -export default function Weather(props) { +function Weather(props) { if (props.temperature >= 20) { return (

@@ -77,6 +78,8 @@ export default function Weather(props) { ); } } + +export default () => ; ``` Note: A component must always return something. @@ -140,14 +143,14 @@ Note: External components are found on npmjs.com and need to be imported first. ```javascript import React from "react"; -export default function Hello(props) { +function Hello(props) { function fullName() { return `${props.firstName} ${props.lastName}`; } return

{fullName()}

; } -; +export default () => ; ``` ## Properties {.cols-2} @@ -539,6 +542,7 @@ Note: Custom Hooks are reusable functions in React that contain logic shared acr to extract stateful logic from components into standalone functions. ### Creating Refs in Class Components + ```javascript import React, { Component } from "react"; @@ -561,8 +565,8 @@ export default MyComponent; ``` ### Using Refs in Functional Components -```javascript +```javascript import React, { useRef, useEffect } from "react"; function MyComponent() { @@ -579,15 +583,15 @@ export default MyComponent; ``` ### Callback Refs -```javascript +```javascript import React, { Component } from "react"; class MyComponent extends Component { constructor(props) { super(props); this.myRef = null; - this.setRef = element => { + this.setRef = (element) => { this.myRef = element; }; } @@ -605,6 +609,7 @@ export default MyComponent; ``` ### Forwarding Refs + ```javascript Copy code import React from "react"; @@ -621,10 +626,10 @@ const ref = React.createRef(); ``` ### Accessing DOM Elements with Refs + ### Refs are often used to access and interact with DOM elements directly. Here's an example where we focus an input element using a ref: ```javascript - import React, { useRef, useEffect } from "react"; function FocusInput() { @@ -642,10 +647,10 @@ export default FocusInput; ``` ### Managing Focus with Refs + ### You can also manage focus between multiple elements using refs: ```javascript - import React, { useRef } from "react"; function Form() { diff --git a/source/_posts/ruby.md b/source/_posts/ruby.md index eee2041..10803dc 100644 --- a/source/_posts/ruby.md +++ b/source/_posts/ruby.md @@ -11,6 +11,7 @@ intro: | The [Ruby](https://www.ruby-lang.org/) cheat sheet is a one-page reference sheet for the Ruby programming language. plugins: - copyCode + - runCode --- ## Getting Started diff --git a/themes/coo/layout/_partial/scripts.ejs b/themes/coo/layout/_partial/scripts.ejs index e5d09a9..8cd3882 100644 --- a/themes/coo/layout/_partial/scripts.ejs +++ b/themes/coo/layout/_partial/scripts.ejs @@ -75,16 +75,22 @@ <% if (is_post() && page.plugins != undefined && page.plugins.includes("runCode") ){ %> +