`
20 | * Quit: `\q`
21 |
22 | ### Creating database
23 |
24 | $ createdb databasename
25 |
--------------------------------------------------------------------------------
/src/components/V2017/CarbonBox.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import { carbon } from '~/config'
3 | const useCarbon = carbon.enabled
4 | ---
5 |
6 |
7 | {useCarbon ? : null}
8 |
9 |
10 |
11 |
12 |
13 |
14 |
18 |
--------------------------------------------------------------------------------
/src/lib/links.ts:
--------------------------------------------------------------------------------
1 | import { github } from '~/config'
2 | import type { SheetPage } from './page'
3 |
4 | export function getEditLink(page: { slug: string } | null | undefined) {
5 | if (!page) return null
6 | return `${github.repositoryUrl}/blob/${github.branch}/${page.slug}.md`
7 | }
8 |
9 | export function getUrlFromPage(
10 | page?: SheetPage | undefined,
11 | siteUrl?: URL | undefined
12 | ) {
13 | if (!siteUrl) throw new Error('No site URL found')
14 | if (!page) return siteUrl.toString()
15 | if (page.slug) return `${siteUrl}${page.slug}`
16 | throw new Error("Can't get URL from page")
17 | }
18 |
--------------------------------------------------------------------------------
/premailer.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Premailer
3 | tags: [WIP]
4 | intro: |
5 | [Premailer](https://github.com/premailer/premailer/) is a Ruby library that inlines CSS into HTML.
6 | ---
7 |
8 | ### Custom CSS properties
9 |
10 |
11 | ```css
12 | table, th, td {
13 | /* Available on table, th and td elements */
14 | -premailer-width: 32px;
15 | }
16 |
17 | table, tr, th, td {
18 | /* Available on table, tr, th and td elements */
19 | -premailer-height: 32px;
20 | }
21 |
22 | table {
23 | /* Available on table elements */
24 | -premailer-cellpadding: 32px;
25 | -premailer-cellspacing: 32px;
26 | }
27 | ```
28 |
--------------------------------------------------------------------------------
/src/sass/2017/components/search-footer.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Search bar around the footer
3 | */
4 |
5 | .search-footer {
6 | & {
7 | @include section-with-container;
8 | padding-top: 16px;
9 | padding-bottom: 16px;
10 | background: $gray-bg;
11 | border-top: solid 1px $dark-line-color;
12 | border-bottom: solid 1px $dark-line-color;
13 | }
14 | }
15 |
16 | .search-footer-section {
17 | & {
18 | display: flex;
19 | }
20 |
21 | & > .search {
22 | flex: 0 1 640px;
23 | }
24 |
25 | & > .links {
26 | @include gutter(padding-left);
27 | flex: 0 1 auto;
28 | margin-left: auto;
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/lib/page/accessors.ts:
--------------------------------------------------------------------------------
1 | /*
2 | * Accessors: things that get stuff from a specific record. Usually in the form
3 | * of `get(page, ...) -> any`
4 | */
5 |
6 | import type { SheetPage } from '../page'
7 |
8 | /**
9 | * Check if a page has a tag
10 | */
11 |
12 | export function hasTag(page: SheetPage, tagName: string): boolean {
13 | return (
14 | (page.frontmatter.tags && page.frontmatter.tags.includes(tagName)) || false
15 | )
16 | }
17 |
18 | /**
19 | * Checks if something should appear on the homepage
20 | */
21 |
22 | export function isListed(page: SheetPage): boolean {
23 | return page.frontmatter.category !== 'Hidden'
24 | }
25 |
--------------------------------------------------------------------------------
/src/pages/__tests__/sitemap.xml.test.ts:
--------------------------------------------------------------------------------
1 | import { GET } from '../sitemap.xml'
2 |
3 | let lines: string[]
4 |
5 | beforeEach(async () => {
6 | if (lines) return
7 | const response = await GET()
8 | const body = await response.text()
9 | lines = body.split('\n')
10 | })
11 |
12 | test('has data', async () => {
13 | expect(lines).toContain('https://devhints.io/react')
14 | expect(lines).toContain('https://devhints.io/bash')
15 | })
16 |
17 | test('skip unlisted sheets', async () => {
18 | expect(lines).not.toContain(
19 | 'https://devhints.io/tests/basic'
20 | )
21 | })
22 |
--------------------------------------------------------------------------------
/frequency-separation-retouching.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Frequency separation retouching
3 | category: Others
4 | ---
5 |
6 | ### Frequency separation retouching in Photoshop
7 |
8 | Duplicate the layer twice. Perform these in each layer:
9 | {: .-setup}
10 |
11 | #### Lower layer
12 |
13 | - Apply **Gaussian Blur**
14 |
15 | #### Upper layer
16 |
17 | - Set layer mask to **Linear light**
18 | - Image → **Apply Image**
19 | - Layer: _(select the lower layer)_
20 | - Blending mode: `Subtract`
21 | - Scale: `2`
22 | - Offset: `128`
23 |
24 | ### Reference
25 |
26 | -
27 | {: .-also-see}
28 |
--------------------------------------------------------------------------------
/src/components/V2017Sheet/SearchFooter.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import SearchForm from './SearchForm.astro'
3 | ---
4 |
5 |
17 |
18 |
23 |
--------------------------------------------------------------------------------
/animated_gif.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Animated GIFs
3 | category: CLI
4 | ---
5 |
6 | ## Animated GIFs
7 | {: .-one-column}
8 |
9 | ### Convert MP4 to GIF
10 |
11 | ```bash
12 | mkdir -p gif
13 | mplayer -ao null -vo gif89a:outdir=gif $INPUT
14 | mogrify -format gif *.png
15 | gifsicle --colors=256 --delay=4 --loopcount=0 --dither -O3 gif/*.gif > ${INPUT%.*}.gif
16 | rm -rf gif
17 | ```
18 |
19 | You'll need `mplayer`, `imagemagick` and `gifsicle`. This converts frames to .png, then turns them into an animated gif.
20 |
21 | ### A given range
22 |
23 | ```bash
24 | mplayer -ao null -ss 0:02:06 -endpos 0:05:00 -vo gif89a:outdir=gif videofile.mp4
25 | ```
26 |
27 | See `-ss` and `-endpos`.
28 |
--------------------------------------------------------------------------------
/src/sass/2017/components/h2-section.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * h2 section
3 | */
4 |
5 | .h2-section {
6 | // Hide first h2 heading
7 | @apply [&:first-child>h2]:hidden;
8 |
9 | // Space between
10 | @apply md:mt-16 md:first-of-type:mt-0;
11 | }
12 |
13 | .h2-section h2 {
14 | @apply font-manrope font-extrabold tracking-[-0.02em];
15 | @apply text-3xl text-zinc-950 target:text-mildindigo-600;
16 | @apply scroll-mt-6;
17 | }
18 |
19 | a.local-anchor {
20 | @apply text-2xl ml-2 text-mildindigo-500 opacity-0;
21 | @apply hover:opacity-100 focus:opacity-100;
22 | @apply hover:no-underline;
23 | }
24 |
25 | .h2-section h2:hover a.local-anchor {
26 | @apply opacity-100;
27 | }
28 |
--------------------------------------------------------------------------------
/src/scripts/v2017/behaviors_2/dismiss.js:
--------------------------------------------------------------------------------
1 | import { getData } from '../helpers/data'
2 | import * as Dismiss from '../helpers/dismiss'
3 |
4 | /**
5 | * Dismiss button
6 | */
7 |
8 | export function setupDismiss() {
9 | document.querySelectorAll('[data-js-dismiss]').forEach((el) => {
10 | const parent = el.closest('[data-js-dismissable]')
11 | const dismissable = getData(parent, 'js-dismissable')
12 | const id = (dismissable && dismissable.id) || ''
13 |
14 | el.addEventListener('click', (e) => {
15 | Dismiss.setDismissed(id)
16 | e.preventDefault()
17 | if (parent && parent.parentNode) parent.parentNode.removeChild(parent)
18 | })
19 | })
20 | }
21 |
--------------------------------------------------------------------------------
/analytics.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Analytics libraries
3 | category: Analytics
4 | ---
5 |
6 | ### Mixpanel
7 |
8 | ```js
9 | mixpanel.identify('284');
10 | mixpanel.people.set({ $email: 'hi@gmail.com' });
11 | mixpanel.register({ age: 28, gender: 'male' }); /* set common properties */
12 | ```
13 |
14 | [mixpanel](./mixpanel)
15 | {: .-crosslink}
16 |
17 | ### Google Analytics's analytics.js
18 |
19 | ```js
20 | ga('create', 'UA-XXXX-Y', 'auto');
21 | ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' });
22 | ```
23 |
24 | ```js
25 | ga('send', 'pageview');
26 | ga('send', 'pageview', { 'dimension15': 'My custom dimension' });
27 | ```
28 |
29 | [analytics.js](./analytics.js)
30 | {: .-crosslink}
31 |
--------------------------------------------------------------------------------
/ledger-query.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ledger queries
3 | category: Ledger
4 | ---
5 |
6 | ### About
7 |
8 | -
9 |
10 | ### Query characters
11 |
12 | | Query | Description |
13 | | --- | --- |
14 | | `@payee` | Payee |
15 | | `%tag` | Tag |
16 | | `=note` | Note |
17 | | `#code` | Code |
18 | | --- | --- |
19 | | `TERM and TERM` | Boolean and |
20 | | `TERM or TERM` | Boolean or |
21 | | `not TERM` | Boolean not |
22 |
23 | ### Examples
24 |
25 | ```sh
26 | ledger r @taco
27 | ledger r comment =~ /landline/
28 | ```
29 |
--------------------------------------------------------------------------------
/phoenix@1.2.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Phoenix 1.2
3 | category: Elixir
4 | weight: -1
5 | updated: 2018-03-06
6 | ---
7 |
8 | See [Phoenix](./phoenix) for a more updated cheatsheet.
9 |
10 | ### Directory structure (Legacy 1.2)
11 |
12 | ```
13 | ├── _build
14 | ├── config/
15 | ├── deps/
16 | ├── lib/
17 | │ ├── hello/
18 | │ ├── hello.ex
19 | ├── node_modules/
20 | ├── priv/
21 | ├── test/
22 | └── web/
23 | │ ├── channels/
24 | │ ├── controllers/
25 | │ ├── models/
26 | │ ├── static/
27 | │ ├── templates/
28 | │ ├── views/
29 | │ ├── gettext.ex
30 | │ ├── router.ex
31 | │ ├── web.ex
32 | ├── mix.exs
33 | ```
34 |
35 | This is Phoenix 1.2's structure. Phoenix 1.3 has no `models`.
36 |
--------------------------------------------------------------------------------
/src/sass/2017/components/push-button.scss:
--------------------------------------------------------------------------------
1 | .push-button {
2 | display: inline-block;
3 | text-decoration: none;
4 | padding: 8px 16px;
5 | border-radius: 3px;
6 |
7 | &,
8 | &:visited {
9 | background-color: $base-a;
10 | background: $base-a-gradient;
11 | color: white;
12 | }
13 |
14 | &:hover,
15 | &:focus {
16 | background: darken($base-a, 16%);
17 | box-shadow: none;
18 | color: white;
19 | }
20 | }
21 |
22 | .push-button.-dark {
23 | &,
24 | &:visited {
25 | background: darken($base-a, 16%);
26 | color: white;
27 | }
28 |
29 | &:hover,
30 | &:focus {
31 | background: darken($base-a, 24%);
32 | color: white;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/types/JsonLdDocument.ts:
--------------------------------------------------------------------------------
1 | export type JsonLdNewsArticle = {
2 | '@context': 'http://schema.org'
3 | '@type': 'NewsArticle'
4 | mainEntityOfPage: {
5 | '@type': 'WebPage'
6 | '@id': string
7 | }
8 | headline: string
9 | image: string[]
10 | description: string
11 | }
12 |
13 | export type JsonLdListItem = {
14 | '@type': 'ListItem'
15 | position: number
16 | item: {
17 | '@id': string
18 | name: string
19 | }
20 | }
21 |
22 | export type JsonLdBreadcrumbList = {
23 | '@context': 'http://schema.org'
24 | '@type': 'BreadcrumbList'
25 | itemListElement: JsonLdListItem[]
26 | }
27 |
28 | export type JsonLdDocument = JsonLdNewsArticle | JsonLdBreadcrumbList
29 |
--------------------------------------------------------------------------------
/src/scripts/v2017/helpers/dismiss.js:
--------------------------------------------------------------------------------
1 | import * as Store from './store'
2 |
3 | /**
4 | * Dismisses an announcement.
5 | *
6 | * @example
7 | * setDismissed('2017-09-02-happy-birthday')
8 | */
9 |
10 | export function setDismissed(id) {
11 | Store.update('dismissed', function (data) {
12 | data[id] = true
13 | return data
14 | })
15 | }
16 |
17 | /**
18 | * Checks if an announcement has been dismissed before.
19 | *
20 | * @example
21 | * setDismissed('2017-09-02-happy-birthday')
22 | * isDismissed('2017-09-02-happy-birthday') => true
23 | */
24 |
25 | export function isDismissed(id) {
26 | const data = Store.fetch('dismissed')
27 | return data && data[id]
28 | }
29 |
--------------------------------------------------------------------------------
/src/sass/2017/components/autocomplete.scss:
--------------------------------------------------------------------------------
1 | // Overrides for npm:autocompleter
2 |
3 | .autocomplete {
4 | border: none;
5 | padding: 0.5rem;
6 | padding-top: 0;
7 | border-bottom-left-radius: 4px;
8 | border-bottom-right-radius: 4px;
9 | box-shadow: $shadow3;
10 | transform: translate(-8px, -2px);
11 | }
12 | .autocomplete > div {
13 | padding: 0.5rem;
14 | border-radius: 4px;
15 | }
16 | .autocomplete > div:hover:not(.group) {
17 | background: $base-body;
18 | }
19 | .autocomplete > div + div:not(.selected) {
20 | box-shadow: inset 0 1px $line-color;
21 | }
22 | .autocomplete > div.selected,
23 | .autocomplete > div.selected:hover {
24 | background: $base-c;
25 | color: #fff;
26 | }
27 |
--------------------------------------------------------------------------------
/handlebars.js.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Handlebars.js
3 | category: JavaScript libraries
4 | weight: -1
5 | ---
6 |
7 | {% raw %}
8 |
9 | ### Helpers
10 |
11 | ```js
12 | Handlebars.registerHelper('link_to', function() {
13 | return "" + this.body + "";
14 | })
15 | ```
16 |
17 | ```js
18 | var context = { posts: [{url: "/hello-world", body: "Hello World!"}] }
19 | var source = "{{#posts}}- {{{link_to}}}
{{/posts}}
"
20 | ```
21 |
22 | ```js
23 | var template = Handlebars.compile(source)
24 | template(context)
25 | ```
26 |
27 | Would render:
28 |
29 | ```html
30 |
33 | ```
34 |
35 | {% endraw %}
36 |
--------------------------------------------------------------------------------
/social-images.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Social media images
3 | ---
4 |
5 | ### Facebook
6 |
7 | | What | Dimensions |
8 | |:---- | ----------:|
9 | | Cover photo | 851 x 315 |
10 | | Display picture | 168 x 168 ? |
11 | | Highlighted image | 1200 x 717 (appears 843 x 504) |
12 | | Share link (og:image) | 940 x 492 (1.91:1, appears as 470 x 246) |
13 | | Share link (square) | 1:1, appears as 114 x 114? |
14 |
15 | ### Twitter
16 |
17 | | What | Dimensions |
18 | |:---- | ----------:|
19 | | Page header | 1500 x 500 |
20 | | Display picture | 400 x 400 (shown as 200x200) |
21 | | In-stream photo preview | 440 x 220 (2:1) |
22 |
23 | ### References
24 |
25 | *
26 |
--------------------------------------------------------------------------------
/src/sass/2017/components/home-button.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Home button inside `search-footer`
3 | */
4 |
5 | .home-button {
6 | & {
7 | display: inline-block;
8 | box-shadow: inset 0 0 0 1px $dark-line-color;
9 | border-radius: 50%;
10 | }
11 |
12 | &,
13 | &:visited {
14 | color: $base-mute;
15 | }
16 |
17 | &:hover,
18 | &:focus {
19 | background-color: $base-a;
20 | color: white;
21 | }
22 |
23 | & > i::before {
24 | content: '';
25 | @include ion-ios-home-outline(24px, $base-mute);
26 | height: 48px;
27 | line-height: 48px;
28 | width: 48px;
29 | }
30 |
31 | &:hover > i::before {
32 | background-image: ion-ios-home-image(white);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/components/V2017Sheet/RelatedPostItem.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import type { SheetPage } from '~/lib/page'
3 |
4 | export type Props = {
5 | class?: string
6 | page: SheetPage
7 | }
8 | const props = Astro.props as Props
9 | const page = props.page
10 | const url = `/${page.slug}`
11 |
12 | const t = {
13 | suffix: 'cheatsheet'
14 | }
15 | ---
16 |
17 |
18 |
19 | {page.frontmatter.title}
20 | {' '}
21 |
22 | {t.suffix}
23 |
24 |
25 |
26 |
27 |
31 |
--------------------------------------------------------------------------------
/harvey.js.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Harvey.js
3 | category: JavaScript libraries
4 | intro: |
5 | [Harvey.js](http://harvesthq.github.io/harvey/) helps you build responsive interfaces.
6 | ---
7 |
8 | ### Usage
9 |
10 | ```js
11 | Harvey.attach('(min-width: 600px)', {
12 | setup: function () {
13 | // Called on first enter
14 | },
15 | on: function () {
16 | // Called on every enter
17 | },
18 | off: function () {
19 | // Called on every exit
20 | }
21 | })
22 | ```
23 |
24 | ### Deprecated
25 |
26 | Harvey.js hasn't been updated in a while, as of time of writing. Consider [enquire.js](https://github.com/WickyNilliams/enquire.js) instead.
27 |
28 | ### References
29 |
30 | *
31 |
--------------------------------------------------------------------------------
/google-webfonts.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Google Webfonts
3 | intro: |
4 | Short snippets on using [Google Webfonts](https://google.com/fonts) in a web page.
5 | ---
6 |
7 | ### Link tag
8 |
9 |
10 | ```html
11 |
12 | ```
13 |
14 | ### CSS import
15 |
16 |
17 | ```css
18 | /* One font */
19 | @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,700');
20 |
21 | /* Combining multiple fonts */
22 | @import url('https://fonts.googleapis.com/css?family=Open+Sans:400,400italic|Montserrat:400,700'');
23 | ```
24 |
25 | Great for using with [Codepen.io](https://codepen.io/) or similar websites!
26 |
--------------------------------------------------------------------------------
/nodejs-path.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Node.js path API
3 | category: Node.js
4 | intro: |
5 | Quick reference to the [Node.js path API](https://nodejs.org/api/path.html).
6 | ---
7 |
8 | ### Functions
9 |
10 | ```js
11 | const fs = require('fs')
12 |
13 | fs.realpath('/etc/passwd', function (err, path) {
14 | path // => "/private/etc/passwd"
15 | })
16 | ```
17 |
18 | ```js
19 | const path = require('path')
20 | dir = path.join('etc', 'passwd')
21 | dir = path.resolve('/etc', 'passwd', '..', 'var')
22 | ```
23 |
24 | ```js
25 | path.dirname('/etc/passwd') // => "/etc"
26 | path.basename('/etc/passwd') // => "passwd"
27 | path.basename('/etc/rc.d', '.d') // => "rc"
28 | ```
29 |
30 | ### References
31 |
32 | - https://nodejs.org/api/path.html
33 |
--------------------------------------------------------------------------------
/ruby21.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ruby 2.1
3 | category: Ruby
4 | tags: [Archived]
5 | intro: |
6 | Quick reference to the [new features in Ruby 2.1](https://www.ruby-lang.org/).
7 | ---
8 |
9 | ### Named arguments with defaults
10 |
11 | ```ruby
12 | # length is required
13 | def pad(num, length:, char: "0")
14 | num.to_s.rjust(length, char)
15 | end
16 | ```
17 |
18 | ```ruby
19 | pad(42, length: 6) #=> "000042"
20 | pad(42) #=> #
21 | ```
22 |
23 | ### Module.prepend
24 |
25 | ```ruby
26 | prepend(
27 | Module.new do
28 | define_method ...
29 | end
30 | )
31 | ```
32 |
33 | ### References
34 |
35 | - http://globaldev.co.uk/2013/03/ruby-2-0-0-in-detail
36 | - http://globaldev.co.uk/2014/05/ruby-2-1-in-detail
37 |
--------------------------------------------------------------------------------
/saucelabs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Saucelabs
3 | ---
4 |
5 | ### Getting started
6 |
7 | Sign up for opensauce:
8 | {: .-setup}
9 |
10 | - http://saucelabs.com/opensauce
11 |
12 | Install [zuul](https://npmjs.com/package/zuul):
13 |
14 | ```
15 | npm i -g zuul
16 | ```
17 |
18 | Configure zuul:
19 |
20 | ```yml
21 | # ~/.zuulrc
22 | sauce_username: me
23 | sauce_key: abc12348-e3e2-...
24 | ```
25 |
26 | Add `.zuul.yml` to your project:
27 |
28 | ```yml
29 | # .zuul.yml
30 | ui: mocha-bdd
31 | browsers:
32 | - name: chrome
33 | version: latest
34 | - name: ie
35 | version: 6..latest
36 | - name: firefox
37 | version: latest
38 | ```
39 |
40 | Try to run tests:
41 |
42 | ```
43 | zuul test/test.js
44 | zuul --local test/test.js
45 | ```
46 |
--------------------------------------------------------------------------------
/src/lib/fuseSearch/__snapshots__/fuseSearch.test.ts.snap:
--------------------------------------------------------------------------------
1 | // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2 |
3 | exports[`Simple pages scenario > multi-result search 1`] = `
4 | [
5 | {
6 | "item": {
7 | "slug": "react",
8 | "title": "React",
9 | },
10 | "refIndex": 0,
11 | },
12 | {
13 | "item": {
14 | "slug": "react-router",
15 | "title": "React Router",
16 | },
17 | "refIndex": 2,
18 | },
19 | ]
20 | `;
21 |
22 | exports[`Simple pages scenario > no-result search 1`] = `[]`;
23 |
24 | exports[`Simple pages scenario > one-result search 1`] = `
25 | [
26 | {
27 | "item": {
28 | "slug": "vim",
29 | "title": "Vim",
30 | },
31 | "refIndex": 1,
32 | },
33 | ]
34 | `;
35 |
--------------------------------------------------------------------------------
/src/sass/2017/markdown/ul.scss:
--------------------------------------------------------------------------------
1 | @use 'sass:math';
2 |
3 | .MarkdownBody ul.-six-column {
4 | & {
5 | display: flex;
6 | flex-wrap: wrap;
7 | }
8 |
9 | & > li {
10 | flex: 0 0 math.div(100%, 6);
11 |
12 | @media (max-width: 480px) {
13 | flex: 0 0 (100% * 0.5);
14 | }
15 |
16 | @media (max-width: 768px) {
17 | flex: 0 0 (100% * 0.25);
18 | }
19 | }
20 | }
21 |
22 | .MarkdownBody ul.-four-column {
23 | & {
24 | display: flex;
25 | flex-wrap: wrap;
26 | }
27 |
28 | & > li {
29 | flex: 0 0 (100% * 0.25);
30 |
31 | @media (max-width: 480px) {
32 | flex: 0 0 (100% * 0.5);
33 | }
34 |
35 | @media (max-width: 768px) {
36 | flex: 0 0 math.div(100%, 3);
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/virtual-dom.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Virtual-dom
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About
7 |
8 | See
9 |
10 | ### Example
11 |
12 | ```js
13 | var h = require('virtual-dom/h')
14 | var diff = require('virtual-dom/diff')
15 | var patch = require('virtual-dom/patch')
16 | var createElement = require('virtual-dom/create-element')
17 | ```
18 |
19 | ### Rendering
20 |
21 | ```js
22 | tree = h('div', { style: { color: 'blue' } }, [ 'hello' ])
23 | el = createElement(tree)
24 | document.body.appendChild(root)
25 | ```
26 |
27 | ### Updating
28 |
29 | ```js
30 | tree2 = h('div', { style: { color: 'blue' } }, [ 'hello world' ])
31 | delta = diff(tree, tree2)
32 | el = patch(el, delta) // patch() modifies el
33 | ```
34 |
--------------------------------------------------------------------------------
/watchman.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Watchman
3 | updated: 2017-10-18
4 | weight: -1
5 | keywords:
6 | - "watchman watch ~/src"
7 | - "watchman watch-list"
8 | - "watchman -- trigger ~/rsc remake '*.js' -- make "
9 | ---
10 |
11 | ### Getting started
12 |
13 | ```bash
14 | watchman watch ./src
15 | ```
16 |
17 | Adds `./src` to the watch list.
18 |
19 | ```bash
20 | watchman -- trigger ./src retest '*.js' -- npm test
21 | ```
22 |
23 | Adds a trigger called `retest` to run `npm test` every time `*.js` changes in `./src`.
24 |
25 | ### Watching
26 |
27 | ```
28 | watchman watch ~/src
29 | watchman watch-list
30 | watchman watch-del ~/src
31 | ```
32 |
33 | ## Also see
34 |
35 | * [Documentation](https://facebook.github.io/watchman/docs/install.html) _(facebook.github.io)_
36 |
--------------------------------------------------------------------------------
/src/scripts/v2017/helpers/inject_disqus.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Injects disqus's scripts into the page.
3 | *
4 | * @example
5 | * inject('devhints.disqus.com')
6 | */
7 |
8 | export default function inject(host) {
9 | injectEmbed(host)
10 | injectCount(host)
11 | }
12 |
13 | export function injectEmbed(host) {
14 | const d = document
15 | const s = d.createElement('script')
16 | s.src = `https://${host}/embed.js`
17 | s.setAttribute('data-timestamp', +new Date())
18 | ;(d.head || d.body).appendChild(s)
19 | }
20 |
21 | export function injectCount(host) {
22 | const d = document
23 | const s = d.createElement('script')
24 | s.src = `https://${host}/count.js`
25 | s.id = 'dsq-count-scr'
26 | s.async = true
27 | ;(d.head || d.body).appendChild(s)
28 | }
29 |
--------------------------------------------------------------------------------
/src/scripts/v2017/helpers/store.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Updates a local storage key. If it doesn't exist, it defaults to an empty
3 | * object.
4 | *
5 | * @example
6 | * update('dismissed', (data) => {
7 | * data.lol = true
8 | * return data
9 | * })
10 | */
11 |
12 | export function update(key, fn) {
13 | if (!window.localStorage) return
14 | let data = JSON.parse(window.localStorage[key] || '{}')
15 | data = fn(data)
16 | window.localStorage[key] = JSON.stringify(data)
17 | }
18 |
19 | /**
20 | * Fetches a local storage key.
21 | *
22 | * @example
23 | * const data = fetch('dismissed')
24 | */
25 |
26 | export function fetch(key) {
27 | if (!window.localStorage) return
28 | return JSON.parse(window.localStorage[key] || '{}')
29 | }
30 |
--------------------------------------------------------------------------------
/spreadsheet.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Spreadsheet functions
3 | tags: [WIP]
4 | ---
5 |
6 | ### If
7 |
8 | ```
9 | =IF(test, then, else)
10 | =IF(EQ(A1, "paid"), "true", "false")
11 | ```
12 |
13 | ### Comparators
14 |
15 | ```
16 | =EQ(a,b)
17 | =NE(a,b)
18 | =GT(a,b)
19 | =GTE(a,b)
20 | =LT(a,b)
21 | =LTE(a,b)
22 | ```
23 |
24 | ### Math
25 |
26 | ```
27 | =POW(2, 32) # 2^32
28 | =SIN() ACOS() etc
29 | =CEILING(n,sig,mode)
30 | =FLOOR(n,sig,mode)
31 | =INT(n)
32 | ```
33 |
34 | ```
35 | =SUM(range)
36 | ```
37 |
38 | ```
39 | =SUMIF(range, criteria, sum_range)
40 | =SUMIF(A1:A5, ">300", B1:B5) # if A# is >300, use B#
41 | ```
42 |
43 | ### Core
44 |
45 | ```
46 | =TO_DATE(number)
47 | ```
48 |
49 | ### Vlook
50 |
51 | ```
52 | =VLOOKUP(value, range, column_index)
53 | ```
54 |
--------------------------------------------------------------------------------
/src/analytics/GoogleAnalytics.astro:
--------------------------------------------------------------------------------
1 | ---
2 | type Props = { measurementId: string }
3 | const props = Astro.props as Props
4 | const measurementId = props.measurementId
5 | ---
6 |
7 |
10 | {/* prettier-ignore */}
11 |
26 |
--------------------------------------------------------------------------------
/gh-pages.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: GitHub pages
3 | category: Jekyll
4 | ---
5 |
6 | ## Custom domains
7 |
8 | ### Custom domains
9 |
10 | ```sh
11 | $ echo "foobar.com" > CNAME
12 | $ git commit && git push
13 | ```
14 |
15 | Create a `CNAME` file with your domain on it.
16 |
17 | See: [Setting up a custom domain](https://help.github.com/articles/quick-start-setting-up-a-custom-domain/) _(github.com)_
18 |
19 | ### Set up your domain
20 |
21 | Subdomain (like www):
22 | {: .-setup}
23 |
24 | CNAME => username.github.io
25 |
26 | Apex domains:
27 | {: .-setup}
28 |
29 | ALIAS => username.github.io
30 |
31 | Apex domains (alternative):
32 | {: .-setup}
33 |
34 | A => 192.30.252.153
35 | A => 192.30.252.154
36 |
37 | ## References
38 | {: .-one-column}
39 |
40 | -
41 |
--------------------------------------------------------------------------------
/ledger-csv.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ledger CSV format
3 | category: Ledger
4 | ---
5 |
6 | ## Ledger CSV format
7 | {: .-one-column}
8 |
9 | ```
10 | $ ledger csv
11 | ```
12 | {: .-setup}
13 |
14 | ```csv
15 | date , code , desc , account , currency , amt , pending/cleared , notes
16 | "2013/09/02" , "" , "things" , "Assets:Cash" , "P" , "-2000" , "*" , ""
17 | "2013/09/02" , "" , "things" , "Liabilities:Card" , "P" , "-200" , "*" , ""
18 | "2013/09/02" , "" , "things" , "Expenses:Things" , "P" , "2200" , "*" , ""
19 | "2013/09/04" , "" , "stuff" , "Assets:Cash" , "P" , "-20" , "*" , ""
20 | "2013/09/04" , "" , "stuff" , "Expenses:Others" , "P" , "20" , "*" , ""
21 | ```
22 |
--------------------------------------------------------------------------------
/css-antialias.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: CSS antialiasing
3 | category: CSS
4 | updated: 2017-10-13
5 | intro: |
6 | Here's a 4-line snippet on how to get beautiful, antialiased text with CSS.
7 | ---
8 |
9 | ### Antialias
10 | {: .-prime}
11 |
12 | ```css
13 | * {
14 | -webkit-font-smoothing: antialiased;
15 | -moz-osx-font-smoothing: grayscale;
16 | }
17 | ```
18 |
19 | ### Support
20 |
21 | * Firefox 25+ on OSX
22 | * Webkits (Chrome, Safari, etc)
23 |
24 | ## References
25 | {: .-one-column}
26 |
27 | * [maxvoltar.com](http://maxvoltar.com/archive/-webkit-font-smoothing)
28 | * [maximilianhoffman.com](http://maximilianhoffmann.com/posts/better-font-rendering-on-osx)
29 | * [ilikekillnerds.com](http://ilikekillnerds.com/2010/12/a-solution-to-stop-font-face-fonts-looking-bold-on-mac-browsers/)
30 | {: .-also-see}
31 |
--------------------------------------------------------------------------------
/public/_redirects:
--------------------------------------------------------------------------------
1 | /brew /homebrew 301
2 | /commander-js /commander.js 301
3 | /css-animation /css#animation 301
4 | /css-background /css#background 301
5 | /css-font /css#fonts 301
6 | /css-selectors /css#selectors 301
7 | /date /datetime 301
8 | /es2015 /es6 301
9 | /es2016 /es6 301
10 | /es2017 /es6 301
11 | /es2018 /es6 301
12 | /expect.js /expectjs 301
13 | /factory_girl /factory_bot 301
14 | /fetch /js-fetch 301
15 | /flexbox /css-flexbox 301
16 | /flowtype /flow 301
17 | /gpgconf /gnupg 301
18 | /gpg /gnupg 301
19 | /gutom /ph-food-delivery 301
20 | /handlebars-js /handlebars.js 301
21 | /harvey-js /harvey.js 301
22 | /immutable-js /immutable.js 301
23 | /jade /pug 301
24 | /jinja2 /jinja 301
25 | /package.json /package-json 301
26 | /package /package-json 301
27 | /phoenix-ecto@1.3 /phoenix-ecto 301
28 | /sh /bash 301
29 |
--------------------------------------------------------------------------------
/src/components/V2017Sheet/SearchForm.script.ts:
--------------------------------------------------------------------------------
1 | import autocomplete from 'autocompleter'
2 | import { fetchFuse, parseFuse } from '~/lib/fuseSearch/fuseSearch'
3 |
4 | export async function setup(input: HTMLInputElement) {
5 | let fuse
6 |
7 | autocomplete<{ label: string; value: string }>({
8 | input,
9 | fetch: async (text: string, update) => {
10 | fuse ??= parseFuse(await fetchFuse())
11 |
12 | const rows: Array<{ item: { title: string; slug: string } }> =
13 | fuse.search(text, { limit: 10 })
14 |
15 | update(
16 | rows.map((row) => ({ label: row.item.title, value: row.item.slug }))
17 | )
18 | },
19 | onSelect: (item) => {
20 | // ^ { label, value }
21 | const slug = item.value
22 | window.location.href = `/${slug}`
23 | }
24 | })
25 | }
26 |
--------------------------------------------------------------------------------
/ansi.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ansi codes
3 | category: CLI
4 | intro: |
5 | Quick reference to ANSI color codes.
6 | ---
7 |
8 | ### Format
9 |
10 | ```
11 | \033[#m
12 | ```
13 |
14 | ### ANSI codes
15 |
16 | ```
17 | 0 clear
18 | 1 bold
19 | 4 underline
20 | 5 blink
21 |
22 | 30-37 fg color
23 | 40-47 bg color
24 |
25 | 1K clear line (to beginning of line)
26 | 2K clear line (entire line)
27 | 2J clear screen
28 | 0;0H move cursor to 0;0
29 |
30 | 1A move up 1 line
31 | ```
32 |
33 | ### Colors
34 |
35 | ```
36 | 0 black
37 | 1 red
38 | 2 green
39 | 3 yellow
40 | 4 blue
41 | 5 magenta
42 | 6 cyan
43 | 7 white
44 | ```
45 |
46 | ### Bash utilities
47 |
48 | ```sh
49 | hide_cursor() { printf "\e[?25l"; }
50 | show_cursor() { printf "\e[?25h"; }
51 | ```
52 |
--------------------------------------------------------------------------------
/vagrant.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Vagrant
3 | category: Devops
4 | intro: |
5 | [Vagrant](http://vagrantup.com) lets you build isolated virtual environments for your apps.
6 | ---
7 |
8 | ### Get started
9 |
10 | Add some base boxes:
11 | {: .-setup}
12 |
13 | ```bash
14 | vagrant box add precise64 http://files.vagrantup.com/precise64.box
15 | ```
16 |
17 | Work it:
18 |
19 | ```bash
20 | mkdir test_box
21 | cd test_box
22 | vagrant init precise64
23 | ```
24 |
25 | Run it:
26 |
27 | ```bash
28 | vagrant up
29 | vagrant ssh
30 | ```
31 |
32 | To stop, use one of the following:
33 |
34 | ```bash
35 | vagrant ssh # then: sudo shutdown -h now
36 | vagrant suspend
37 | vagrant destroy # !!
38 | ```
39 |
40 | ### Also see
41 |
42 | * [Vagrant website](http://vagrantup.com) _(vagrantup.com)_
43 | * [Vagrantfile cheatsheet](./vagrantfile)
44 |
--------------------------------------------------------------------------------
/zombie.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Zombie
3 | category: JavaScript libraries
4 | intro: |
5 | [Zombie](http://zombie.js.org/) is a full-stack testing solution for Node.js.
6 | ---
7 |
8 | ## Zombie
9 |
10 | ### Examples
11 |
12 | ```js
13 | browser
14 | .visit("http://.../", ->)
15 | .fill("email", "zombie@underworld.dead")
16 | .fill("password", "eat-the-living")
17 | .select("Born", "1985")
18 | .uncheck("Send newsletter")
19 | .clickLink("Link name")
20 | .pressButton("Sign", () => { ... })
21 | .text("H1")
22 | ```
23 |
24 | ### Expectations
25 |
26 | ```js
27 | expect(browser.query("#brains"))
28 |
29 | expect(browser.body.queryAll(".hand")).length 2
30 |
31 | console.log(browser.html())
32 | console.log(browser.html("table.parts"))
33 |
34 | expect(Browser.text(".card-nopad small"), "A better way to get around!")
35 | ```
36 |
--------------------------------------------------------------------------------
/commander.js.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Commander.js
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | -
10 |
11 | ### Initialize
12 |
13 | var cli = require('commander');
14 |
15 | ### Options
16 |
17 | cli
18 | .version(require('../package').version)
19 | .usage('[options] ')
20 | .option('-w, --words ', 'generate words')
21 | .option('-i, --interval ', 'interval [1000]', 1000)
22 | .option('-s, --symbols', 'include symbols')
23 | .parse(process.argv);
24 |
25 | ### Help
26 |
27 | .on('--help', function() {
28 | console.log('');
29 | })
30 |
31 | ### Commands
32 |
33 | cli.outputHelp();
34 | cli.args == ["hello"];
35 |
36 | ### Other useful things
37 |
38 | process.exit(0);
39 |
40 |
41 |
--------------------------------------------------------------------------------
/rename.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: rename
3 | category: CLI
4 | ---
5 |
6 | ### Installation
7 |
8 | ```bash
9 | brew install rename
10 | ```
11 |
12 | See:
13 |
14 | ### Regex substitution
15 |
16 | ```bash
17 | rename 's/hello/world/' *.txt
18 | ```
19 |
20 | Rename `hello.txt` to `world.txt` and so on in `*.txt`.
21 |
22 | ### Replace extension
23 |
24 | ```bash
25 | rename -s .png .jpg.png *.png
26 | ```
27 |
28 | Replace `.png` with `.jpg.png` in `*.png`.
29 |
30 | ### Options
31 |
32 | | Option | Description |
33 | | --- | --- |
34 | | `-n` | Simulation |
35 | | `-l` | Symlink instead of rename |
36 | | `-i` | Interactive |
37 |
38 | ## Also see
39 |
40 | - [Rename website](http://plasmasturm.org/code/rename/) _(plasmasturm.org)_
41 |
--------------------------------------------------------------------------------
/src/sass/2017/markdown/headings.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * MarkdownBody context
3 | */
4 |
5 | .MarkdownBody h2 {
6 | @include heading-style;
7 | @include font-size(6);
8 | line-height: 1.2;
9 | font-weight: 200;
10 | font-family: $heading-font;
11 | margin-top: 0;
12 | }
13 |
14 | .MarkdownBody h3 {
15 | margin: 0;
16 | padding: 0;
17 | margin-bottom: 16px;
18 | font-family: $heading-font;
19 | @include font-size(2);
20 | font-weight: 400;
21 | color: $base-a;
22 | }
23 |
24 | .MarkdownBody {
25 | a,
26 | a:visited {
27 | color: $base-b;
28 | text-decoration: none;
29 | }
30 |
31 | a:hover {
32 | text-decoration: underline;
33 | }
34 |
35 | em {
36 | font-style: normal;
37 | color: $gray-text;
38 | }
39 |
40 | iframe {
41 | border: 0;
42 | margin: 0;
43 | width: 100%;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/top.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: top
3 | category: CLI
4 | updated: 2020-01-01
5 | intro: See the processes in your Unix machine.
6 | ---
7 |
8 | ### Shortcuts
9 |
10 | | Shortcut | Description |
11 | | --------- | --------------------- |
12 | | `h` | shows help |
13 | | `q` | quits the program |
14 | | `m` | switches memory view |
15 | | `1` | switches cpu view |
16 | | `k` | kills process |
17 | | `Shift+p` | sorts by CPU usage |
18 | | `Shift+m` | sorts by memory usage |
19 | | `Shift+r` | reverses sorting |
20 | | `Shift+l` | searches for string |
21 | | `o` | adds a filter |
22 | | `u` | filter user |
23 | | `=` | clears filters |
24 | | `V` | Forest view |
25 | | `c` | show full path |
26 | {: .-shortcuts}
27 |
--------------------------------------------------------------------------------
/applinks.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Applinks
3 | category: HTML
4 | ---
5 |
6 | ### About
7 |
8 | -
9 |
10 | ### Applinks
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ### Device types
23 |
24 | * `ios`
25 | * `ipad`
26 | * `iphone`
27 | * `android`
28 | * `windows_phone`
29 | * `web`
30 |
31 | ### Reference
32 |
33 | * [applinks.org](http://applinks.org/documentation/)
34 |
--------------------------------------------------------------------------------
/immutable.js.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Immutable.js
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Maps
7 |
8 | ```js
9 | var map = Immutable.Map({ a: 1, b: 2, c: 3 })
10 | ```
11 |
12 | ```js
13 | map
14 | .set('b', 50)
15 | .get('b') // 50
16 | ```
17 |
18 | ### Lists
19 |
20 | ```js
21 | var list = Immutable.List.of(1, 2)
22 |
23 | list
24 | .push(3, 4, 5)
25 | .unshift(0)
26 | .concat(list2, list3)
27 | .get(0)
28 | .size
29 | ```
30 |
31 | ### Nested maps
32 |
33 | ```js
34 | var nested = Immutable.fromJS({ user: { profile: { name: 'John' } } })
35 |
36 | nested
37 | // Update
38 | .mergeDeep({ user: { profile: { age: 90 } } })
39 | .setIn([ 'user', 'profile', 'name' ], 'Jack')
40 | .updateIn([ 'user', 'profile', 'name' ], (s) => s.toUpperCase())
41 |
42 | // Get
43 | .getIn(['user', 'profile', 'name']) // 'JACK'
44 | ```
45 |
--------------------------------------------------------------------------------
/ie_bugs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Legacy IE bugs
3 | category: HTML
4 | updated: 2018-03-06
5 | intro: |
6 | A bunch of bugs to take care of if you're going to target legacy IE browsers.
7 | ---
8 |
9 | ### IE8: 'change' event
10 |
11 | The 'change' event doesn't always fire. Not for checkboxes, radios, multi-select lists. Use the `click` handler instead.
12 |
13 | * [(1)](http://stackoverflow.com/questions/8005442/checkbox-change-event-works-when-click-the-label-in-ie8-ie7)
14 |
15 | ### IE8: label with input
16 |
17 | Clicking label with input inside doesn't focus the input.
18 |
19 | * [(1)](http://www.gtalbot.org/BrowserBugsSection/MSIE7Bugs/LabelForWithImage.html)
20 |
21 | ### IE8: Opacity propagation
22 |
23 | An element's 'opacity' value isn't propagated to its positioned descendants.
24 |
25 | * [test case](http://jhop.me/tests/bugs/ie8/opacity_positioned.html)
26 |
--------------------------------------------------------------------------------
/astro.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'astro/config'
2 | import partytown from '@astrojs/partytown'
3 |
4 | /*
5 | * https://astro.build/config
6 | */
7 | import tailwind from '@astrojs/tailwind'
8 |
9 | // https://astro.build/config
10 | export default defineConfig({
11 | site: 'https://devhints.io',
12 | build: {
13 | format: 'file' /* generate /my-post.html instead of /my-post/index.html */,
14 | inlineStylesheets: 'always'
15 | },
16 | prefetch: {
17 | prefetchAll: true
18 | },
19 | server: {
20 | host: true
21 | } /* access from https://192.168.x.x/ */,
22 | integrations: [
23 | partytown({
24 | config: {
25 | forward: ['dataLayer.push']
26 | }
27 | }),
28 | tailwind()
29 | ],
30 | markdown: {
31 | // Syntax highlighting is handled by render()
32 | syntaxHighlight: false
33 | }
34 | })
35 |
--------------------------------------------------------------------------------
/elixir-metaprogramming.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Elixir metaprogramming
3 | category: Elixir
4 | ---
5 |
6 | ### Kernel
7 |
8 | Most of these magic is defined in [Kernel.SpecialForms](http://devdocs.io/elixir/elixir/kernel.specialforms).
9 |
10 | ### Pseudo-variables
11 |
12 | ```elixir
13 | __DIR__ # current dir
14 | __MODULE__ # current module
15 | __CALLER__ # caller of the function
16 | ```
17 |
18 | ### [`__ENV__`](http://devdocs.io/elixir/elixir/kernel.specialforms#__ENV__/0)
19 |
20 | ```elixir
21 | Map.keys(__ENV__)
22 | [:__struct__, :aliases, :context, :context_modules, :export_vars, :file,
23 | :function, :functions, :lexical_tracker, :line, :macro_aliases, :macros,
24 | :module, :requires, :vars]
25 | ```
26 |
27 | ```elixir
28 | __CALLER__.module |> Module.definitions_in |> IO.inspect
29 | ```
30 |
31 | ```elixir
32 | apply(Enum, :reverse, [[1, 2, 3]])
33 | ```
34 |
--------------------------------------------------------------------------------
/flashlight.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Flashlight
3 | category: Apps
4 | ---
5 |
6 | ## Commands
7 | {: .-three-column}
8 |
9 | ### Events and reminders
10 |
11 | * `add Dinner with Rico 5 pm tomorrow`
12 | * `remind Go to school at 2:30pm`
13 | * `remind Go to school in 15 mins`
14 |
15 | ### DuckDuckGo
16 |
17 | * `!g foo`
18 | * `!mdn settimeout`
19 |
20 | ### System
21 |
22 | * `shutdown`
23 | * `restart`
24 | * `logout`
25 | * `sleep`
26 | * `ejall`
27 | * `screen saver`
28 |
29 | ### Emoji
30 |
31 | * `emoji grin`
32 | * `:rocket:`
33 |
34 | ### Web search
35 |
36 | * `/react`
37 |
38 | Prefix with `/` to do a web search.
39 |
40 | ### References
41 |
42 | * [Flashlight](http://flashlight.nateparrott.com/)
43 | * [Flashlight on GitHub](https://github.com/nate-parrott/Flashlight)
44 | * [Creating a plugin](https://github.com/nate-parrott/Flashlight/wiki/Creating-a-Plugin)
45 |
--------------------------------------------------------------------------------
/sql-join.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: SQL joins
3 | category: Databases
4 | updated: 2018-12-06
5 | weight: -1
6 | ---
7 |
8 | ### Example
9 |
10 | ```
11 | SELECT * FROM order_items \
12 | LEFT OUTER JOIN orders \
13 | ON order_items.order_id = orders.id
14 | ```
15 | {: .-wrap}
16 |
17 | Joins are typically added to `SELECT` statements to add more columns and records.
18 |
19 | ### Diagram
20 |
21 | ```
22 | SELECT * FROM `A` INNER JOIN `B`
23 | ```
24 | {: .-setup}
25 |
26 | ```
27 | ┌────────┐
28 | │ A ┌───┼────┐
29 | │ │ ∩ │ │
30 | └────┼───┘ B │
31 | └────────┘
32 | ```
33 | {: .-box-chars.-setup}
34 |
35 | | Join | What |
36 | | ---- | ---- |
37 | | Inner join | `∩` |
38 | | Left outer join | `A` + `∩` |
39 | | Right outer join | `∩` + `B` |
40 | | Full outer join | `A` + `∩` + `B` |
41 |
--------------------------------------------------------------------------------
/qunit.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Qunit
3 | category: JavaScript libraries
4 | intro: |
5 | A quick reference for the [QUnit](https://yarnpkg.com/package/qunit) testing library in JavaScript.
6 | ---
7 |
8 | ```js
9 | QUnit.module('a')
10 | QUnit.test('ok', function (t) {
11 | /* ... */
12 | })
13 | ```
14 |
15 | ### Hooks
16 |
17 | #### Each test
18 |
19 | ```js
20 | // each test
21 | QUnit.testStart(function)
22 | QUnit.testEnd(function)
23 | ```
24 |
25 | ```js
26 | // each module
27 | QUnit.moduleStart(function)
28 | QUnit.moduleEnd(function)
29 | ```
30 |
31 | ```js
32 | // all
33 | QUnit.begin(function)
34 | QUnit.done(function)
35 | ```
36 |
37 | ### Assertions
38 |
39 | ```js
40 | t.equal(actual, expected)
41 | t.deepEqual(actual, expected)
42 | t.strictEqual(actual, expected)
43 | t.propEqual(actual, expected)
44 | t.notEqual(actual, expected)
45 | t.expect(amount)
46 | ```
47 |
--------------------------------------------------------------------------------
/znc.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: ZNC bouncer
3 | intro: |
4 | A quick reference to the [ZNC](https://znc.bg) IRC bouncer's common commands.
5 | ---
6 |
7 | ## Start
8 |
9 | ```
10 | /msg *status addserver irc.undernet.org [6667]
11 | /msg *status connect
12 |
13 | /msg *status loadmod webadmin
14 | /msg *status loadmod admin
15 | /msg *status loadmod away
16 | /msg *status loadmod awaynick
17 | /msg *status loadmod clientnotify # Notifies when another client logs
18 | /msg *status loadmod keepnick
19 | /msg *status loadmod kickrejoin
20 | ```
21 |
22 | ## Away
23 |
24 | ```
25 | /msg *status loadmod away
26 | /msg *away away
27 | /msg *away back
28 | /msg *away show #=> Show messages
29 | /msg *away delete all
30 | ```
31 |
32 | ## Watch
33 |
34 | ```
35 | /msg *status loadmod watch
36 | /msg *watch list
37 | /msg *watch add * *watch *rico*
38 | /msg *watch add * *watch *%nick%*
39 | ```
40 |
--------------------------------------------------------------------------------
/cordova.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Apache Cordova
3 | intro: |
4 | A quick reference to common [Apache Cordova](https://cordova.apache.org/) commands.
5 | ---
6 |
7 | ### Common commands
8 |
9 | ```
10 | cordova plugin ls
11 | cordova plugin search facebook
12 | cordova plugin add com.phonegap.plugins.facebookconnect
13 | ```
14 |
15 | ```
16 | cordova platform add ios
17 | cordova platform ls
18 | cordova platform update ios
19 | cordova platform check
20 | ```
21 |
22 | ### Common plugins
23 |
24 | Some commonly-used plugins:
25 |
26 | - [org.apache.cordova.console](https://github.com/apache/cordova-plugin-console)
27 | - [org.apache.cordova.inappbrowser](https://github.com/apache/cordova-plugin-inappbrowser)
28 | - [org.apache.cordova.statusbar](https://github.com/apache/cordova-plugin-statusbar)
29 | - org.apache.cordova.splashscreen
30 |
31 | Also:
32 |
33 | - com.phonegap.plugins.facebookconnect
34 |
--------------------------------------------------------------------------------
/siege.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Siege
3 | category: Others
4 | intro: |
5 | [Siege](https://www.joedog.org/siege-home/) is an HTTP and HTTPS load testing tool.
6 | ---
7 |
8 | ### Basic usage
9 |
10 | ```sh
11 | siege -b -c=10 -t=5m "http://..."
12 | ```
13 |
14 | ### Options
15 |
16 | #### Repetitions
17 |
18 | ```
19 | -c, --concurrent=N
20 | -t, --time=MINSm
21 | -r, --reps=N
22 | ```
23 |
24 | #### Modes
25 |
26 | ```
27 | -i, --internet Hit URLs randomly
28 | -b, --benchmark No delay between requests
29 | ```
30 |
31 | #### Configuration
32 |
33 | ```
34 | -f, --file=FILE load urls.txt
35 | -R, --rc=FILE load siegerc
36 | ```
37 |
38 | #### Headers
39 |
40 | ```
41 | -H, --header="Cookie: foo=bar"
42 | -A, --user-agent="Mozilla"
43 | -T, --content-type="text/html"
44 | ```
45 |
46 | ### References
47 |
48 | Also see: [siegerc](https://gist.github.com/stansmet/3067988)
49 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Devhints
2 |
3 |
4 | TL;DR for developer documentation - a ridiculous collection of cheatsheets
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | ✨ devhints.io ✨
13 |
14 |
15 |
16 |
17 | ---
18 |
19 | See [CONTRIBUTING.md](CONTRIBUTING.md) for developer notes.
20 |
21 | [](https://gitpod.io/#https://github.com/rstacruz/cheatsheets)
22 |
23 | Similar projects
24 |
25 | - [Command Line Interface Pages](https://github.com/command-line-interface-pages)
26 | - [tldr-pages](https://github.com/tldr-pages/tldr)
27 | - [Cheat](https://github.com/cheat/cheat)
28 | - [Eg](https://github.com/srsudar/eg)
29 |
--------------------------------------------------------------------------------
/analytics.js.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Google Analytics's analytics.js
3 | category: Analytics
4 | updated: 2017-10-29
5 | intro: |
6 | Google Analytics's analytics.js is deprecated.
7 | ---
8 |
9 | ### Page view
10 |
11 | ```js
12 | ga('create', 'UA-XXXX-Y', 'auto')
13 | ga('create', 'UA-XXXX-Y', { userId: 'USER_ID' })
14 | ```
15 |
16 | ```js
17 | ga('send', 'pageview')
18 | ga('send', 'pageview', { 'dimension15': 'My custom dimension' })
19 | ```
20 |
21 | ### Events
22 |
23 | ```js
24 | ga('send', 'event', 'button', 'click', {color: 'red'});
25 | ```
26 |
27 | ```js
28 | ga('send', 'event', 'button', 'click', 'nav buttons', 4);
29 | /* ^category ^action ^label ^value */
30 | ```
31 |
32 | ### Exceptions
33 |
34 | ```js
35 | ga('send', 'exception', {
36 | exDescription: 'DatabaseError',
37 | exFatal: false,
38 | appName: 'myapp',
39 | appVersion: '0.1.2'
40 | })
41 | ```
42 |
--------------------------------------------------------------------------------
/less.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Less.js
3 | ---
4 |
5 | ### Functions
6 |
7 | unit(30px / 5px) #=> 6
8 | unit(5, px) #=> 5px
9 |
10 | e("ms:stuff()") #=> ms:stuff() (unquote)
11 |
12 | %("count: %d", 1+2) #=> "count: 3"
13 |
14 | iscolor(@x)
15 | isstring(@x)
16 | isnumber(@x)
17 | iskeyword(@x)
18 | isurl(url(...))
19 | ispixel()
20 | isem()
21 | ispercentage()
22 | isunit()
23 |
24 | hue(@color)
25 | saturation(@color)
26 | lightness(@color)
27 | luma(@color)
28 | luminance(@color)
29 |
30 | fade(@color, amount)
31 | fadein(@color, amount)
32 | fadeout(@color, amount)
33 | spin(@color, degrees)
34 | mix(@a, @b, amount)
35 |
36 | ### Conditionals
37 |
38 | .image when (luma(@color) > 50%) { }
39 | .image when (not(...)) { }
40 | .image when (default()) {}
41 | .image when (e(@shape) = 'circle') { }
42 |
43 |
--------------------------------------------------------------------------------
/src/scripts/v2017/behaviors_2/disqus.js:
--------------------------------------------------------------------------------
1 | import { onScrollVisible } from '~/lib/domutils/onScrollVisible'
2 | import injectDisqus from '../helpers/inject_disqus'
3 |
4 | /**
5 | * Injects Disqus onto the page.
6 | */
7 |
8 | export function setupDisqus() {
9 | document.querySelectorAll('[data-js-disqus]').forEach((el) => {
10 | const data = JSON.parse(el.getAttribute('data-js-disqus'))
11 | const $parent = el.parentNode
12 |
13 | onScrollVisible($parent, () => {
14 | activateDisqus(data, $parent)
15 | })
16 | })
17 | }
18 |
19 | function activateDisqus(data, $parent) {
20 | $parent.setAttribute('hidden', true)
21 |
22 | window.disqus_config = function () {
23 | this.page.url = data.url
24 | this.page.identifier = data.identifier
25 | }
26 |
27 | // Disqus takes a while to load, don't do it so eagerly.
28 | injectDisqus(data.host)
29 | $parent.removeAttribute('hidden')
30 | }
31 |
--------------------------------------------------------------------------------
/haml.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Haml
3 | category: Markup
4 | prism_languages: [haml]
5 | ---
6 |
7 | ### Doctype
8 |
9 | ```haml
10 | !!! 5
11 | ```
12 |
13 | ### Tags
14 |
15 | ```haml
16 | %html
17 | %head
18 | %title
19 | %body
20 | %h1 Hello World
21 | %br/
22 | ```
23 |
24 | ### Classes and ID's
25 |
26 | ```haml
27 | %p.class-example
28 | .no-tag-defaults-to-div
29 | %div#butItCanBeIncluded
30 | ```
31 |
32 | ### Inline Attributes
33 |
34 | Either hash syntax works
35 |
36 | ```haml
37 | %meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
38 | %input{ :type => "text", :required => true }
39 | ```
40 |
41 | ### Ruby
42 |
43 | ```haml
44 | -# This is a comment
45 | -# Anything starting with a hyphen signals to Haml that Ruby is coming
46 | - @arr = [1, 2, 3]
47 | - @str = "test"
48 | -# Equal signals output
49 | = render partial: "shared/header"
50 | = yield
51 | = link_to page_url
52 | ```
53 |
--------------------------------------------------------------------------------
/mocha.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Mocha.js
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### BDD
7 |
8 | mocha.setup('bdd');
9 |
10 | describe('something', function() {
11 | beforeEach(function() {
12 | });
13 |
14 | it('should work', function() {
15 | });
16 | });
17 |
18 | ### Async
19 |
20 | it('should save', function(done) {
21 | var user = new User();
22 | user.save(function(err) {
23 | if (err) throw err;
24 | done();
25 | });
26 | });
27 |
28 | ### Chai: Shoulds
29 |
30 | chai.should();
31 |
32 | foo.should.be.a('string');
33 | foo.should.equal('bar');
34 | foo.should.have.length(3);
35 | tea.should.have.property('flavors').with.length(3);
36 |
37 | ### See also
38 |
39 | * [Mocha TDD](mocha-tdd.html)
40 | * [Mocha HTML](mocha-html.html)
41 | * [Chai](chai.html)
42 | * [Sinon](sinon.html)
43 | * [Sinon Chai](sinon-chai.html)
44 |
--------------------------------------------------------------------------------
/src/types/SheetFrontmatter.ts:
--------------------------------------------------------------------------------
1 | import { z } from 'zod'
2 |
3 | export const SheetFrontmatterSchema = z.object({
4 | title: z
5 | .union([z.string(), z.number()])
6 | .transform((x) => x.toString())
7 | .pipe(z.string())
8 | .optional(),
9 |
10 | category: z.string().optional(),
11 | weight: z.number().optional(),
12 | tags: z.string().array().optional(),
13 | updated: z.date().optional(),
14 | keywords: z
15 | .string()
16 | .array()
17 | .optional()
18 | .describe(
19 | 'Search keywords. Appears in meta descriptions, and helps in search.'
20 | ),
21 | deprecated_by: z.string().optional().describe('Name of newer sheet'),
22 | intro: z
23 | .string()
24 | .optional()
25 | .describe(
26 | 'Introduction text in Markdown. Appears above the fold and on meta descriptions.'
27 | )
28 | })
29 |
30 | export type SheetFrontmatter = z.infer
31 |
--------------------------------------------------------------------------------
/js-lazy.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: JavaScript lazy shortcuts
3 | category: JavaScript
4 | ---
5 |
6 | ## Shortcuts
7 | {: .-left-reference}
8 |
9 | ### Examples
10 |
11 | ```js
12 | n = +'4096' // n === 4096
13 | s = '' + 200 // s === '200'
14 | ```
15 |
16 | ```js
17 | now = +new Date()
18 | isPublished = !!post.publishedAt
19 | ```
20 |
21 | ### Shortcuts
22 |
23 | | What | Lazy mode | "The right way" |
24 | | --- | --- | --- |
25 | | String to number | `+str` | `parseInt(str, 10)` _or_ `parseFloat()` |
26 | | Math floor | `num | 0` | `Math.floor(num)` |
27 | | Number to string | `'' + num` | `num.toString()` |
28 | | Date to UNIX timestamp | `+new Date()` | `new Date().getTime()` |
29 | | Any to boolean | `!!value` | `Boolean(value)` |
30 | | Check array contents | `if (~arr.indexOf(v))` | `if (arr.includes(v))` |
31 | {: .-left-align.-headers}
32 |
33 | `.includes` is ES6-only, otherwise use `.indexOf(val) !== -1` if you don't polyfill.
34 |
--------------------------------------------------------------------------------
/nodejs-process.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: process
3 | category: Node.js
4 | ---
5 |
6 | ### Streams
7 |
8 | process.stdout.write('...');
9 | process.stderr.write('...');
10 |
11 | function stdin(fn) {
12 | var data = '';
13 |
14 | process.stdin.setEncoding('utf8');
15 | process.stdin.on('readable', function() {
16 | var chunk = process.stdin.read();
17 | if (chunk !== null) data += chunk;
18 | });
19 |
20 | process.stdin.on('end', function() {
21 | fn(null, data);
22 | });
23 | }
24 |
25 | ### stuff
26 |
27 | process.argv; //=> ['node', 'file.js', 'one', 'two']
28 | process.env; //=> {TERM: 'screen-256color', SHELL: '/bin/bash', ...}
29 |
30 | process.exit();
31 | process.exit(1);
32 |
33 | ### Directories
34 |
35 | process.cwd(); //=> "/tmp"
36 | process.chdir('dir');
37 |
38 | ### References
39 |
40 | - http://nodejs.org/api/process.html
41 |
--------------------------------------------------------------------------------
/src/sass/2017/components/missing-message.scss:
--------------------------------------------------------------------------------
1 | .missing-message.missing-message {
2 | text-align: center;
3 | margin: 32px 0;
4 | display: flex;
5 | align-items: center;
6 | border-top: solid 1px $dark-line-color;
7 | padding-top: 16px;
8 |
9 | @media (min-width: 769px) {
10 | padding-top: 32px;
11 | }
12 |
13 | & > h3,
14 | & > p {
15 | margin: 0;
16 | padding: 0;
17 | }
18 |
19 | & > h3 {
20 | @include font-size(1);
21 | font-weight: normal;
22 | color: $base-text;
23 | flex: 1 0 auto;
24 | text-align: left;
25 | }
26 |
27 | & > h3::before {
28 | content: '';
29 | @include ion-md-arrow-forward(24px, $base-a);
30 | margin-right: 16px;
31 | }
32 |
33 | & > p {
34 | color: $base-mute;
35 | flex: 0 0 auto;
36 | }
37 |
38 | @media (max-width: 480px) {
39 | flex-wrap: wrap;
40 |
41 | & > p {
42 | margin-top: 16px;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/jquery.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: jQuery
3 | category: JavaScript libraries
4 | tags: [WIP]
5 | weight: -1
6 | ---
7 |
8 | ### Traversing
9 |
10 | ```js
11 | $('.box')
12 | .children()
13 | .closest('div')
14 | .filter(':selected')
15 | .find('div')
16 | .has('div')
17 | .first()
18 | .next('div')
19 | .nextUntil('div')
20 | ```
21 |
22 | ## Advanced features
23 |
24 | ### Extending selectors
25 |
26 | ```js
27 | $.expr[':'].inline = function (el) {
28 | return $(el).css('display') === 'inline'
29 | }
30 | ```
31 |
32 | Enables `$(':inline')`
33 |
34 | ### Extend CSS properties
35 |
36 | ```js
37 | $.cssHooks.someCSSProp = {
38 | get: function (elem, computed, extra) {
39 | },
40 | set: function (elem, value) {
41 | }
42 | }
43 |
44 | // Disable "px"
45 | $.cssNumber["someCSSProp"] = true
46 | ```
47 |
48 | ### fn.animate() hooks
49 |
50 | ```js
51 | $.fn.step.someWhatever = function(fx) {
52 | // ...
53 | }
54 | ```
55 |
--------------------------------------------------------------------------------
/vimscript-snippets.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Vimscript snippets
3 | category: Vim
4 | ---
5 |
6 | ### Bind function to key and command
7 |
8 | command! YoFunctionHere call s:YoFunctionHere()
9 | nnoremap x :call FunctionHere()
10 | function! s:FunctionHere()
11 | endfunction
12 |
13 | ### Call a function in insert mode
14 |
15 | inoremap X =script#myfunction()
16 | inoremap =MyVimFunc()?'':''
17 |
18 | ### Checking plugins
19 |
20 | if globpath(&rtp, "plugin/commentary.vim") != ""
21 |
22 | ## Autoload
23 |
24 | " autoload/hello.vim
25 | if exists("g:hello_loaded") | finish | endif
26 | let g:hello_loaded=1
27 |
28 | function hello#method()
29 | endfunction
30 |
31 | " calling hello#method() will load only if autoload()
32 |
33 | ## Misc
34 |
35 | ### Version check
36 |
37 | if version < 704
38 | echom "requires vim >= 7.4"
39 | endif
40 |
41 |
--------------------------------------------------------------------------------
/bookshelf.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bookshelf.js
3 | category: JavaScript libraries
4 | ---
5 |
6 | Model
7 | -----
8 |
9 | ### Model
10 | ```js
11 | Summary = bookshelf.Model.extend({
12 | tableName: 'summaries',
13 | hasTimestamps: true,
14 | hasTimestamps: ['created_at', 'updated_at'],
15 | })
16 | ```
17 |
18 | ### Associations
19 |
20 | ```js
21 | Summary = bookshelf.Model.extend({
22 | book () {
23 | return this.belongsTo(Book)
24 | },
25 | author () {
26 | return this.hasOne(Author)
27 | }
28 | // belongsToMany
29 | // hasMany
30 | // hasMany().through()
31 | })
32 | ```
33 |
34 | ### CRUD
35 |
36 | ```js
37 | Book.create({ title: '..' }).save()
38 | new Book({ title: '..' }).save()
39 |
40 | new Book({ id: 1 }).fetch()
41 |
42 | Book.where({ id: 1 }).fetch()
43 | Book.where('favorite_color', 'red').fetch()
44 | Book.where('favorite_color', '<>', 'red').fetch()
45 | Book
46 | .query((q) => q.orderBy('updated_at')
47 | ```
48 |
--------------------------------------------------------------------------------
/src/pages/sitemap.xml.ts:
--------------------------------------------------------------------------------
1 | import { site } from '~/config'
2 | import { getPages } from '~/lib/page'
3 | import { isListed } from '~/lib/page/accessors'
4 |
5 | export async function GET() {
6 | const lines = [
7 | ``,
8 | ``
9 | ]
10 |
11 | const visiblePages = Object.values(await getPages()).filter(isListed)
12 |
13 | for (const page of visiblePages) {
14 | const url = `${site.url}/${page.slug}`
15 | lines.push(`${url}`)
16 | }
17 |
18 | lines.push(``)
19 |
20 | const data = lines.join('\n') + '\n'
21 |
22 | return new Response(data, {
23 | status: 200,
24 | headers: { 'Content-Type': 'application/xml' }
25 | })
26 | }
27 |
--------------------------------------------------------------------------------
/rubygems.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Rubygems
3 | category: Ruby
4 | intro: |
5 | A quick reference to common [rubygems](https://rubygems.org) CLI commands.
6 | ---
7 |
8 | ### Building and publishing
9 |
10 | ```sh
11 | gem build *.gemspec # Build a gem
12 | gem install *.gem # Install locally
13 | gem push *.gem # Upload to rubygems.org
14 | gem yank foogem -v 0.0.1 # Take it back
15 | ```
16 |
17 | ### Querying
18 |
19 | ```sh
20 | gem owner foogem -a rico@ricostacruz.com
21 |
22 | gem list # List local gems
23 | gem which rake # Point to where lib/rake.rb is
24 | gem search -r rails # [remote] Search for gems
25 | ```
26 |
27 | ### Opening a gem
28 |
29 | ```sh
30 | # https://github.com/fnando/gem-open
31 | gem open foogem
32 | GEM_EDITOR="vim" gem open foogem
33 | ```
34 |
35 | ### Changing to a directory
36 |
37 | ```sh
38 | cd $(basename `gem which rake`) # Go to a gem's path
39 | ```
40 |
--------------------------------------------------------------------------------
/weinre.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Weinre
3 | category: JavaScript libraries
4 | tags: [Archived]
5 | intro: |
6 | [weinre](https://www.npmjs.com/package/weinre) is a remote Web inspector. Note that it has been deprecated since 2016.
7 | archived: Weinre has been deprecated since 2016.
8 | ---
9 |
10 | ### Usage
11 |
12 | #### Install:
13 |
14 | ```
15 | $ npm install -g weinre
16 | ```
17 |
18 | #### Start the server:
19 |
20 | ```
21 | $ weinre --boundHost 0.0.0.0
22 | $ open http://localhost:8080
23 | ```
24 |
25 | ### HTML to inject
26 |
27 |
28 | ```html
29 |
30 | ```
31 |
32 | ### References
33 |
34 | - [Weinre](http://people.apache.org/~pmuellr/weinre/)
35 |
36 |
--------------------------------------------------------------------------------
/blessed.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Blessed
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Screen
7 |
8 | ```js
9 | screen = blessed.screen({
10 | smartCSR: true // optimize for flickering
11 | autoPadding: true // ..
12 | })
13 |
14 | screen.append(Element)
15 | screen.destroy()
16 |
17 | screen.width
18 | screen.height
19 | screen.title = 'My window title'
20 | screen.key(['escape', 'q', 'C-c'], (ch, key) => { ... })
21 | ```
22 |
23 | ### Element
24 |
25 | ```js
26 | box = blessed.box({
27 | style: { fg, bg, border.fg, scrollbar.bg, focus.bg, hover.bg },
28 | border: { type: 'line'|'bg', bg, fg, bold, underline }
29 | tags: true, // parse {bold}tags{/bold}
30 |
31 | top, left, width, height,
32 | width: '100%',
33 | height: '100%-1',
34 | top: 'center'
35 | })
36 | ```
37 |
38 | ### Tags
39 |
40 | ```
41 | {bold}
42 | {right} {center}
43 | {|} left-right separator
44 | {#c0ff33-fg}{/}
45 | ```
46 |
47 | ```
48 | blessed.escape('...')
49 | ```
50 |
--------------------------------------------------------------------------------
/js-appcache.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: applicationCache
3 | category: JavaScript
4 | ---
5 |
6 | ## Reference
7 | {: .-one-column}
8 |
9 | ### applicationCache checking
10 |
11 | ```js
12 | if (window.applicationCache) {
13 | // "Naturally" reload when an update is available
14 | var reload = false
15 |
16 | window.applicationCache.addEventListener('updateready', () => {
17 | if (window.applicationCache.status === window.applicationCache.UPDATEREADY) {
18 | window.applicationCache.swapCache()
19 | reload = true
20 | }
21 | }, false)
22 |
23 | setInterval(() => {
24 | try {
25 | // There's nothing to update for first-time load, browser freaks out :/
26 | window.applicationCache.update()
27 | } catch (e) { }
28 | }, 1000 * 60 * 60) // Every hour
29 | }
30 | ```
31 |
32 | This is a deprecated HTML feature. See: [Using the application cache](https://developer.mozilla.org/en-US/docs/HTML/Using_the_application_cache) _(developer.mozilla.org)_
33 |
--------------------------------------------------------------------------------
/tape.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Tape
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Example
7 |
8 | ```js
9 | test('things', (t) => {
10 | t.plan(1)
11 |
12 | t.equal('actual', 'expected')
13 | t.equal('actual', 'expected', 'should be equal') // messages are optional
14 |
15 | t.end(err)
16 | t.fail('msg')
17 | t.pass('msg')
18 | t.timeoutAfter(2000)
19 | t.skip('msg')
20 |
21 | t.ok(value, 'is truthy')
22 | t.notOk(value, 'is falsy')
23 | t.error(err, 'is falsy (print err.message)')
24 |
25 | t.equal(actual, expected, 'is equal')
26 | t.notEqual
27 |
28 | t.deepEqual(actual, expected, 'is equal (use node's deepEqual)')
29 | t.notDeepEqual
30 |
31 | t.looseEqual(actual, expected, 'is equal (use node's deepEqual with ==)')
32 | t.notLooseEqual
33 |
34 | t.throws(fn, /FooError/)
35 | t.throws(fn, FooError /* class */)
36 | t.doesNotThrow
37 |
38 | t.comment('message')
39 | })
40 | ```
41 |
42 | ```js
43 | test.only((t) => { ... })
44 | ```
45 |
--------------------------------------------------------------------------------
/.eslintrc.cjs:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | module.exports = {
3 | extends: [
4 | 'eslint:recommended',
5 | 'plugin:@typescript-eslint/recommended',
6 | 'plugin:astro/recommended',
7 | 'prettier'
8 | ],
9 | env: {
10 | browser: true // enables window, document, etc
11 | },
12 | parser: '@typescript-eslint/parser',
13 | plugins: ['@typescript-eslint'],
14 | root: true,
15 | ignorePatterns: ['dist/**'],
16 |
17 | overrides: [
18 | {
19 | files: ['*.test.ts'],
20 | rules: {
21 | '@typescript-eslint/no-explicit-any': 'off'
22 | }
23 | },
24 | {
25 | files: ['*.astro'],
26 | parser: 'astro-eslint-parser',
27 | parserOptions: {
28 | parser: '@typescript-eslint/parser',
29 | extraFileExtensions: ['.astro']
30 | }
31 | // rules: {
32 | // override/add rules settings here, such as:
33 | // "astro/no-set-html-directive": "error"
34 | // },
35 | }
36 | ]
37 | }
38 |
--------------------------------------------------------------------------------
/chunky_png.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Chunky PNG
3 | category: Ruby libraries
4 | ---
5 |
6 | ### Loading
7 |
8 | ```ruby
9 | image = ChunkyPNG::Image.from_file('file.png')
10 | ```
11 |
12 | #### Alternate ways
13 |
14 | ```ruby
15 | image = ChunkyPNG::Image.from_blob(File.read('file.png'))
16 | image = ChunkyPNG::Image.from_io(io)
17 | ```
18 |
19 | Loads from `file.png`.
20 |
21 | ### Saving
22 |
23 | ```ruby
24 | image.save('filename.png')
25 | ```
26 |
27 | #### Alternate ways
28 |
29 | ```ruby
30 | File.open('newfile.png', 'wb') { |io| image.write(io) }
31 | binary_string = image.to_blob
32 | ```
33 |
34 | Writes an image to `newfile.png`.
35 |
36 | ### Drawing
37 |
38 | ```ruby
39 | image[0, 0] = ChunkyPNG::Color.rgba(255, 0,0, 128)
40 | image.line(1, 1, 10, 1, ChunkyPNG::Color.from_hex('#aa007f'))
41 | ```
42 |
43 | ### Canvas
44 |
45 | ```ruby
46 | crop(x, y, w, h)
47 | ```
48 |
49 | ### Transforms
50 |
51 | ```ruby
52 | new_image = image.flip_horizontally.rotate_right
53 | ```
54 |
--------------------------------------------------------------------------------
/src/ruby/cache_kramdown.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Caches Kramdown results in .cache/
4 | # Normally, Kramdown is invoked as needed (kramdown.rb), but this is
5 | # going to be slow down builds significantly. By doing all Kramdown
6 | # rendering beforehand, this cuts down the time from 70s to 10s.
7 | require 'fileutils'
8 | require 'digest'
9 | require_relative 'renderer'
10 |
11 | # This seems to default to US-ASCII in some environments, which causes
12 | # errors in some sheets
13 | Encoding.default_external = Encoding::UTF_8
14 |
15 | def remove_frontmatter(input_string)
16 | input_string.sub(/\A(---\s*\n.*?\n?)^((---|\.\.\.)\s*$\n?)/m, '')
17 | end
18 |
19 | FileUtils.mkdir_p '.cache'
20 |
21 | ARGV.each do |filepath|
22 | input = File.read(filepath)
23 | input = remove_frontmatter(input)
24 | digest = Digest::SHA2.hexdigest(input.strip)
25 | outfile = ".cache/#{digest}.html"
26 | output = Renderer.render(input: input)
27 | File.write(outfile, output)
28 | end
29 |
--------------------------------------------------------------------------------
/pass.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Pass
3 | category: CLI
4 | ---
5 |
6 | Reference
7 | ---------
8 |
9 | ### Create
10 |
11 | ```sh
12 | $ pass init [-p]
13 | $ pass git init
14 | $ pass git remote add origin
15 | $ pass git push -u --all
16 | ```
17 |
18 | ### Store
19 |
20 | ```sh
21 | $ pass insert [-m] twitter.com/rsc
22 | $ pass generate [-n] twitter.com/rsc length
23 | ```
24 |
25 | ### Retrieve
26 |
27 | ```sh
28 | $ pass ls twitter.com/
29 | $ pass show twitter.com/rsc
30 | $ pass -c twitter.com/rsc
31 | ```
32 |
33 | ### Search
34 |
35 | ```sh
36 | $ pass find twitter.com
37 | ```
38 |
39 | ### Management
40 |
41 | ```sh
42 | $ pass mv twitter.com twitter.com/rsc
43 | $ pass rm [-rf] twitter.com
44 | $ pass cp twitter.com/rsc twitter.com/ricosc
45 | ```
46 |
47 | ```sh
48 | $ pass edit twitter.com/rsc
49 | ```
50 |
51 | ### Synchronize
52 |
53 | ```sh
54 | $ pass git push
55 | $ pass git pull
56 | ```
57 |
58 | ## References
59 |
60 | *
61 |
--------------------------------------------------------------------------------
/ets.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Erlang ETS
3 | category: Elixir
4 | weight: -1
5 | ---
6 |
7 | ## ETS
8 |
9 | ### Usage
10 |
11 | ```elixir
12 | iex> table = :ets.new(:my_table, [])
13 | 8211
14 | ```
15 |
16 | ```elixir
17 | iex> :ets.insert(table, {:fruit, "Apple"})
18 | iex> :ets.lookup(table, :fruit)
19 | [{:fruit, "Apple"}]
20 | ```
21 |
22 | ```elixir
23 | iex> :ets.delete(table)
24 | iex> :ets.delete_all_objects(table)
25 | ```
26 |
27 | ### Flags
28 |
29 | ```elixir
30 | iex> table = :ets.new(:my_table, [:set, :protected])
31 | ```
32 | {: .-setup}
33 |
34 | | `:set` | no duplicate keys (or: `:ordered_set`, `:bag`, `:duplicate_bag`) |
35 | | `:protected` | only this process can use it (or: `:public`, `:private`) |
36 |
37 | ### Ordered sets
38 |
39 | ```elixir
40 | :ets.first(table)
41 | :ets.last(table)
42 | :ets.next(table, key)
43 | :ets.prev(table, key)
44 | ```
45 |
46 | ## References
47 | {: .-one-column}
48 |
49 | *
50 | *
51 |
--------------------------------------------------------------------------------
/dom-selection.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: DOM Selection
3 | category: JavaScript
4 | intro: |
5 | Quick introduction to the HTML [DOM selection API](https://devdocs.io/dom/selection).
6 | ---
7 |
8 | ## Reference
9 | {: .-three-column}
10 |
11 | ### Selection
12 |
13 | ```js
14 | var sel = document.getSelection()
15 | ```
16 |
17 | See:
18 |
19 | ### Methods
20 |
21 | ```js
22 | sel.removeAllRanges() // deselects
23 | sel.addRange(range) // sets a selection
24 | sel.removeRange(range) // remove a range
25 | ```
26 |
27 | ```js
28 | sel.rangeCount
29 | sel.getRangeAt(0) // get the 0th range
30 | ```
31 |
32 | ### Collapsing
33 |
34 | ```js
35 | sel.collapse(parent, offset)
36 | sel.collapseToEnd()
37 | sel.collapseToStart()
38 | sel.isCollapsed
39 | ```
40 |
41 | ```js
42 | sel.containsNode(node)
43 | ```
44 |
45 | ### Deleting
46 |
47 | ```js
48 | sel.deleteFromDocument()
49 | ```
50 |
51 | ### Events
52 |
53 | ```js
54 | document.addEventListener('selectionchange', () => {})
55 | ```
56 |
--------------------------------------------------------------------------------
/mocha-tdd.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Mocha.js TDD interface
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### TDD
7 |
8 | mocha.setup('tdd');
9 |
10 | suite('something', function() {
11 | setup(function() {
12 | });
13 |
14 | test('should work', function() {
15 | });
16 |
17 | teardown(function() {
18 | });
19 | });
20 |
21 | ### Async
22 |
23 | test('should save', function(done) {
24 | var user = new User();
25 | user.save(function(err) {
26 | if (err) throw err;
27 | done();
28 | });
29 | });
30 |
31 | ### Chai: Expect
32 |
33 | var expect = chai.expect;
34 |
35 | expect(foo).to.be.a('string');
36 | expect(foo).to.equal('bar');
37 | expect(foo).to.have.length(3);
38 | expect(tea).to.have.property('flavors').with.length(3);
39 |
40 | ### See also
41 |
42 | * [Mocha BDD](mocha.html)
43 | * [Mocha HTML](mocha-html.html)
44 | * [Chai](chai.html)
45 | * [Sinon](sinon.html)
46 | * [Sinon Chai](sinon-chai.html)
47 |
--------------------------------------------------------------------------------
/ledger-periods.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ledger periods
3 | category: Ledger
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | -
10 |
11 | ### Usage
12 |
13 | [INTERVAL] [BEGIN] [END]
14 |
15 | #### Intervals
16 |
17 | every day
18 | every week
19 | every month
20 | every quarter
21 | every year
22 | every N days # N is any integer
23 | every N weeks
24 | every N months
25 | every N quarters
26 | every N years
27 | daily
28 | weekly
29 | biweekly
30 | monthly
31 | bimonthly
32 | quarterly
33 | yearly
34 |
35 | #### Begin
36 |
37 | from
38 | since
39 |
40 | #### End
41 |
42 | to
43 | until
44 |
45 | ### Spec
46 |
47 | 2004
48 | 2004/10
49 | 2004/10/1
50 | 10/1
51 | october
52 | oct
53 | this week # or day, month, quarter, year
54 | next week
55 | last week
56 |
57 | ### Examples
58 |
59 | $ ledger r -p "since last month"
60 |
--------------------------------------------------------------------------------
/macos-mouse-acceleration.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Mouse Acceleration
3 | category: macOS
4 | updated: 2018-03-20
5 | weight: -1
6 | keywords:
7 | - "defaults write .GlobalPreferences com.apple.mouse.scaling -1"
8 | intro: |
9 | Disable mouse acceleration with this one weird trick.
10 | ---
11 |
12 | ## Acceleration
13 |
14 |
15 | ### Disabling
16 |
17 | ```bash
18 | defaults write .GlobalPreferences com.apple.mouse.scaling -1
19 | ```
20 |
21 | Note: Log out to take effect. If you change *Tracking Speed* under System Preferences, it will undo this fix. Only affects the mouse, not the trackpad.
22 |
23 | ### Re-enabling
24 |
25 | Under *System Preferences* → *Mouse*, change *Tracking Speed*.
26 |
27 | ### Trackpad acceleration
28 |
29 | ```bash
30 | defaults write .GlobalPreferences com.apple.trackpad.scaling -1
31 | ```
32 |
33 | Works the same way, but only affects trackpads.
34 |
35 | ## References
36 |
37 | - [Disabling mouse acceleration](https://stackoverflow.com/questions/5782884/disabling-mouse-acceleration-in-mac-os-x) _(stackoverflow.com)_
38 |
--------------------------------------------------------------------------------
/src/sass/2017/markdown/p.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Crosslink (eg, phoenix.md)
3 | */
4 |
5 | .MarkdownBody.MarkdownBody {
6 | img {
7 | max-width: 100%;
8 | }
9 | }
10 |
11 | .MarkdownBody.MarkdownBody p.-crosslink {
12 | & > a {
13 | display: block;
14 | text-decoration: none;
15 | color: $base-a;
16 | border-bottom: 0;
17 | box-shadow: none;
18 | margin: -16px;
19 | padding: 16px;
20 | }
21 |
22 | & > a:visited {
23 | color: $base-a;
24 | }
25 |
26 | & > a::before {
27 | content: '';
28 | @include ion-md-arrow-forward(16px, white);
29 | margin-right: 16px;
30 | width: 32px;
31 | height: 32px;
32 | line-height: 32px;
33 | border-radius: 50%;
34 | }
35 |
36 | & > a,
37 | & > a:visited {
38 | &::before {
39 | background-color: $base-a;
40 | color: white;
41 | }
42 | }
43 |
44 | & > a:hover,
45 | & > a:focus {
46 | & {
47 | color: $base-a7;
48 | }
49 |
50 | &::before {
51 | background-color: $base-a7;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/components/V2017Home/Announcements.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import { announcement } from '~/config'
3 | import snarkdown from 'snarkdown'
4 |
5 | const body = snarkdown(announcement.body)
6 | .split('
')
7 | .map((text) => `${text}
`)
8 | .join('')
9 | ---
10 |
11 |
12 |
16 |
{announcement.title}
17 |
18 |
19 |
20 |
21 |
22 |
27 |
28 |
35 |
--------------------------------------------------------------------------------
/scp.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: scp
3 | category: CLI
4 | updated: 2018-12-25
5 | authors:
6 | - github: vastpeng
7 | ---
8 |
9 | ### Usage
10 | {: .-prime}
11 |
12 | ```bash
13 | scp source_path destination_path
14 | ```
15 |
16 | ### Conditions
17 |
18 | ```bash
19 | -r # transfer directory
20 | -v # see the transfer details
21 | -C # copy files with compression
22 | -l 800 # limit bandwidth with 800
23 | -p # preserving the original attributes of the copied files
24 | -P # connection port
25 | -q # hidden the output
26 | ```
27 |
28 | ### Commands
29 |
30 | ```bash
31 | $ scp file user@host:/path/to/file # copying a file to the remote system using scp command
32 | $ scp user@host:/path/to/file /local/path/to/file # copying a file from the remote system using scp command
33 | ```
34 |
35 | ```bash
36 | $ scp file1 file2 user@host:/path/to/directory # copying multiple files using scp command
37 | $ scp -r /path/to/directory user@host:/path/to/directory # Copying an entire directory with scp command
38 | ```
39 |
--------------------------------------------------------------------------------
/src/lib/fuseSearch/fuseSearch.test.ts:
--------------------------------------------------------------------------------
1 | import { buildFuseIndex, parseFuse } from './fuseSearch'
2 |
3 | describe('Simple pages scenario', () => {
4 | // prettier-ignore
5 | const pages = {
6 | "react": { slug: "react", frontmatter: { title: "React" } },
7 | "vim": { slug: "vim", frontmatter: { title: "Vim" } },
8 | "react-router": { slug: "react-router", frontmatter: { title: "React Router" } },
9 | }
10 |
11 | let fuse: ReturnType
12 |
13 | runTest({
14 | label: 'one-result search',
15 | query: 'vim'
16 | })
17 | runTest({
18 | label: 'multi-result search',
19 | query: 'react'
20 | })
21 | runTest({
22 | label: 'no-result search',
23 | query: 'skinamarink'
24 | })
25 |
26 | beforeEach(() => {
27 | const externalData = buildFuseIndex(pages)
28 | fuse = parseFuse(externalData)
29 | })
30 |
31 | function runTest({ label, query }: { label: string; query: string }) {
32 | test(label, () => {
33 | const results = fuse.search(query)
34 | expect(results).toMatchSnapshot()
35 | })
36 | }
37 | })
38 |
--------------------------------------------------------------------------------
/src/sass/2017/components/back-button.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Home link
3 | */
4 |
5 | .back-button {
6 | text-decoration: none;
7 | width: 48px;
8 | height: 48px;
9 | line-height: 48px - 2px;
10 | text-align: center;
11 | display: inline-block;
12 | border-radius: 50%;
13 | transition: all 100ms linear;
14 |
15 | // Smaller on mobile
16 | @media (max-width: 480px) {
17 | width: 32px;
18 | height: 32px;
19 | line-height: 32px - 2;
20 | }
21 |
22 | // Colors
23 | &,
24 | &:visited {
25 | color: $base-mute;
26 | }
27 |
28 | // Active
29 | &:hover,
30 | &:focus {
31 | color: white;
32 | background: $base-a;
33 | opacity: 1;
34 | }
35 |
36 | // Icon
37 | &::before {
38 | content: '';
39 | @include ion-md-arrow-back(24px, $base-text);
40 | vertical-align: middle;
41 | }
42 |
43 | &:hover::before,
44 | &:focus::before {
45 | @include ion-md-arrow-back(24px, white);
46 | }
47 |
48 | // Icon: smaller on mobile
49 | @media (max-width: 480px) {
50 | &::before {
51 | font-size: 16px;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/sass/2017/components/comments-details.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Comments disclosure triangle
3 | */
4 |
5 | .comments-details {
6 | & {
7 | margin-bottom: -16px;
8 | }
9 |
10 | &[open] {
11 | margin-bottom: 0;
12 | }
13 |
14 | & > summary {
15 | @include font-size(1);
16 | color: $base-a;
17 | padding: 24px 0;
18 | white-space: nowrap;
19 | cursor: pointer;
20 | }
21 |
22 | & > summary:hover,
23 | & > summary:focus {
24 | &,
25 | & > .suffix {
26 | color: $base-a7;
27 | }
28 |
29 | & > .fauxlink {
30 | border-bottom: solid 1px $base-a7;
31 | }
32 | }
33 |
34 | & > summary > .count {
35 | font-weight: bold;
36 | }
37 |
38 | & > summary > .count::before {
39 | @include ion-md-chatboxes(24px, $base-a);
40 | content: '';
41 | vertical-align: middle;
42 | color: $base-a;
43 | margin: 0 8px;
44 | }
45 |
46 | & > summary > .suffix {
47 | color: $base-mute;
48 | }
49 |
50 | & > summary > .fauxlink {
51 | margin-left: 4px;
52 | border-bottom: solid 1px rgba($base-a, 0.25);
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/nopt.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Nopt
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | -
10 |
11 | ### Example
12 |
13 | ```js
14 | var args = require('nopt')({
15 | foo: [String, null],
16 | size: ['big', 'medium', 'small'],
17 | many: [String, Array],
18 | debug: Boolean,
19 | version: Boolean,
20 | help: Boolean
21 | }, {
22 | h: '--help',
23 | v: '--version'
24 | }, process.argv);
25 |
26 | args == {
27 | debug: true,
28 | version: true,
29 | size: 'big',
30 | argv: {
31 | remain: ['...', '...'],
32 | cooked: ...,
33 | original: ...
34 | }
35 | }
36 | ```
37 |
38 | ```js
39 | if (args.help) {
40 | console.log([
41 | 'Usage:',
42 | ' hicat [options] [file]',
43 | '',
44 | 'Options:',
45 | ' -h, --help print usage information',
46 | ' -v, --version show version info and exit',
47 | ].join('\n'));
48 | process.exit(0);
49 | }
50 |
51 | if (args.version) {
52 | console.log(require('../package.json').version);
53 | process.exit(0);
54 | }
55 | ```
56 |
--------------------------------------------------------------------------------
/vows.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Vows
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About vows
7 |
8 | * [Vowsjs.org](http://vowsjs.org/)
9 |
10 | ### CoffeeScript usage
11 |
12 | vows = require "vows"
13 | assert = require "assert"
14 |
15 | vows
16 | .describe('My tests')
17 | .addBatch
18 | 'context':
19 | topic: ->
20 | 100
21 | 'should work': (number) ->
22 | assert.equal number, 100
23 |
24 | .export(module)
25 |
26 | ### Running
27 |
28 | vows test/*-test.* --spec
29 |
30 | ### Assertions
31 |
32 | assert.equal a, b
33 | assert.notEqual a, b
34 | assert.strictEqual a, b
35 |
36 | assert.isNaN(number)
37 | assert.instanceOf(object, klass)
38 | assert.isUndefined(object)
39 | assert.isFunction(func)
40 | assert.isNull(object)
41 | assert.isNotZero(object)
42 | assert.isObject(object)
43 | assert.isString(object)
44 |
45 | ### Async
46 |
47 | .addBatch
48 | topic: ->
49 | doStuff()
50 | @callback 2
51 | 'check things': (n) ->
52 | assert.equal 2, n
53 |
--------------------------------------------------------------------------------
/modernizr.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Modernizr
3 | category: JavaScript libraries
4 | tags: [Archived]
5 | archived: Modernizr is no longer in active development.
6 | ---
7 |
8 | ### Script
9 |
10 |
11 |
12 | ### Detections
13 |
14 | JavaScript
15 |
16 | * js
17 |
18 | CSS
19 |
20 | * flexbox
21 | * rgba
22 | * hsla
23 | * multiplebgs
24 | * backgroundsize
25 | * borderimage
26 | * borderradius
27 | * boxshadow
28 | * textshadow
29 | * opacity
30 | * cssanimations
31 | * csscolumns
32 | * cssgradients
33 | * cssreflections
34 | * csstransforms
35 | * csstransforms3d
36 | * csstransitions
37 | * fontface
38 | * generatedcontent
39 |
40 | HTML5
41 |
42 | * canvas
43 | * canvastext
44 | * webgl
45 | * touch
46 | * geolocation
47 | * postmessage
48 | * websqldatabase
49 | * indexeddb
50 | * hashchange
51 | * history
52 | * draganddrop
53 | * websockets
54 | * video
55 | * audio
56 | * localstorage
57 | * sessionstorage
58 | * webworkers
59 | * applicationcache
60 | * svg
61 | * inlinesvg
62 | * smil
63 | * svgclippaths
64 |
--------------------------------------------------------------------------------
/src/sass/2017/components/h3-section-list.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * H3 section list:
3 | * The body that is isotoped.
4 | */
5 |
6 | .h3-section-list {
7 | @apply px-0 gap-6 lg:gap-8 my-0;
8 | // @apply grid grid-cols-3;
9 | }
10 |
11 | .h3-section {
12 | @apply w-full break-inside-avoid;
13 | @apply pb-12 pt-0;
14 | }
15 |
16 | /*
17 | * Two column (default)
18 | */
19 |
20 | .h3-section-list,
21 | .h3-section-list.-two-column {
22 | @media (min-width: 769px) {
23 | columns: 2;
24 | }
25 | }
26 |
27 | /*
28 | * One column
29 | */
30 |
31 | .h3-section-list.-one-column {
32 | @media (min-width: 769px) {
33 | columns: 1;
34 | }
35 |
36 | & > .h3-section + .h3-section {
37 | margin-top: 16px;
38 | }
39 | }
40 |
41 | /*
42 | * Three column
43 | */
44 |
45 | .h3-section-list.-three-column {
46 | @media (min-width: 769px) {
47 | columns: 2;
48 | }
49 |
50 | @media (min-width: 961px) {
51 | columns: 3;
52 | }
53 | }
54 |
55 | .h3-section-list.-left-reference {
56 | @media (min-width: 769px) {
57 | columns: 3;
58 | }
59 |
60 | & > .h3-section + .h3-section {
61 | width: 200%;
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/mocha-html.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Mocha HTML
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About
7 |
8 | This is a mocha template that loads js/css from cdn.
9 |
10 | ### Template
11 |
12 | ```html
13 |
14 |
15 |
16 |
17 | Mocha
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | ```
36 |
--------------------------------------------------------------------------------
/yaml.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Yaml
3 | category: Markup
4 | prism_languages: [yaml]
5 | ---
6 |
7 | ### Dictionaries and lists
8 |
9 | ```yaml
10 | # comments start with "#"
11 | # dictionary are written like "key: value"
12 | name: Martin D'vloper
13 | languages:
14 | perl: Elite
15 | python: Elite
16 | pascal: Lame
17 |
18 | # list items beginn with a "- "
19 | foods:
20 | - Apple
21 | - Orange
22 | - Strawberry
23 | - Mango
24 |
25 | # booleans are lower case
26 | employed: true
27 | ```
28 |
29 |
30 | ### Multiline strings
31 |
32 | ```yaml
33 | # Literal Block Scalar
34 | Multiline: |
35 | exactly as you see
36 | will appear these three
37 | lines of poetry
38 | ```
39 |
40 | ```yaml
41 | # Folded Block Scalar
42 | Multiline: <
43 | this is really a
44 | single line of text
45 | despite appearances
46 | ```
47 |
48 | ### Inheritance
49 |
50 | ```yaml
51 | parent: &defaults
52 | a: 2
53 | b: 3
54 |
55 | child:
56 | <<: *defaults
57 | b: 4
58 | ```
59 |
60 | ### Reference content
61 |
62 | ```yaml
63 | values: &ref
64 | - These values
65 | - will be reused below
66 |
67 | other_values:
68 | <<: *ref
69 | ```
70 |
--------------------------------------------------------------------------------
/applescript.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: AppleScript
3 | updated: 2018-12-06
4 | category: macOS
5 | prism_languages: [applescript]
6 | ---
7 |
8 | ### Running
9 |
10 | ```applescript
11 | osascript -e "..."
12 | ```
13 |
14 | ```applescript
15 | display notification "X" with title "Y"
16 | ```
17 |
18 | ### Comments
19 |
20 | ```applescript
21 | -- This is a single line comment
22 | ```
23 |
24 | ```applescript
25 | # This is another single line comment
26 | ```
27 |
28 | ```applescript
29 | (*
30 | This is
31 | a multi
32 | line comment
33 | *)
34 | ```
35 |
36 | ### Say
37 |
38 | ```applescript
39 | -- default voice
40 | say "Hi I am a Mac"
41 | ```
42 |
43 | ```applescript
44 | -- specified voice
45 | say "Hi I am a Mac" using "Zarvox"
46 | ```
47 |
48 | ### Beep
49 |
50 | ```applescript
51 | -- beep once
52 | beep
53 | ```
54 |
55 | ```applescript
56 | -- beep 10 times
57 | beep 10
58 | ```
59 |
60 | ### Delay
61 |
62 | ```applescript
63 | -- delay for 5 seconds
64 | delay 5
65 | ```
66 |
67 | ### Handlers
68 |
69 | ```applescript
70 | on doubleNumber(n)
71 | return n * 2
72 | end doubleNumber
73 |
74 | set doubledValue to my doubleNumber(2)
75 | ```
76 |
--------------------------------------------------------------------------------
/bolt.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bolt Quickstart
3 | category: Bolt
4 | updated: 2018-12-25
5 | authors:
6 | - github: lucywyman
7 | keywords:
8 | - Puppet
9 | - tasks
10 | - modules
11 | description: |
12 | A quick guide to getting started writing Bolt tasks
13 | ---
14 |
15 | ### Install Bolt
16 |
17 | ```bash
18 | # On MacOS
19 | brew cask install puppetlabs/puppet/puppet-bolt
20 | # On Windows
21 | choco install puppet-bolt
22 | ```
23 |
24 | Bolt is available as a package for most platforms. See [installing bolt](https://puppet.com/docs/bolt/latest/bolt_installing.html)
25 |
26 | ### Create a module with a task
27 |
28 | ```bash
29 | mkdir -p ~/.puppetlabs/bolt/modules/mymodule/tasks
30 | cp myscript.sh ~/.puppetlabs/bolt/modules/mymodule/tasks/
31 | ```
32 |
33 | Tasks can be written in any language your targets can run. See [writing tasks](https://puppet.com/docs/bolt/latest/writing_tasks.html) for more details.
34 |
35 | ### Run Bolt
36 |
37 | ```bash
38 | bolt task run mymodule::myscript -n node1.example.com,node2.example.com --private-key ~/.ssh/id_rsa-private
39 | ```
40 |
41 | See `bolt task run --help` for more information and command line options.
42 |
--------------------------------------------------------------------------------
/src/sass/full.scss:
--------------------------------------------------------------------------------
1 | @import './2017/variables';
2 | @import './2017/utils/font-size';
3 | @import './vendor/modularscale/modularscale';
4 |
5 | /*
6 | * Base
7 | */
8 |
9 | html,
10 | body {
11 | background: $base-body;
12 | font-family: $body-font;
13 | font-size: 14px;
14 | line-height: 1.6;
15 | color: $base-text;
16 | overflow-x: hidden;
17 | }
18 |
19 | body {
20 | @include font-size(0);
21 | padding: 0;
22 | margin: 0;
23 | }
24 |
25 | /*
26 | * Code
27 | */
28 |
29 | pre,
30 | code {
31 | font-family: $monospace-font;
32 | letter-spacing: -0.03em;
33 | }
34 |
35 | pre {
36 | font-size: $code-size;
37 | }
38 |
39 | /*
40 | * Antialias
41 | */
42 |
43 | *:not(pre):not(code) {
44 | -webkit-font-smoothing: antialiased;
45 | -moz-osx-font-smoothing: grayscale;
46 | }
47 |
48 | /*
49 | * Links
50 | */
51 |
52 | a {
53 | color: $base-b;
54 | }
55 |
56 | a:visited {
57 | color: $base-b7;
58 | }
59 |
60 | a:hover {
61 | color: $base-b3;
62 | }
63 |
64 | // No tooltips on mobile
65 | @media (max-width: 580px) {
66 | .hint--bottom {
67 | &::before,
68 | &::after {
69 | display: none;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/test/e2eUtils.ts:
--------------------------------------------------------------------------------
1 | import { expect, type Page } from '@playwright/test'
2 | import type { JsonLdDocument } from '~/types/JsonLdDocument'
3 |
4 | /**
5 | * Helper: assert that a `` tag has a given `name` and `content`
6 | */
7 |
8 | export async function expectMeta(
9 | page: Page,
10 | options:
11 | | { name: string; content: string }
12 | | { property: string; content: string }
13 | ) {
14 | const { content } = options
15 | const metaElement = page.locator(
16 | 'name' in options
17 | ? `meta[name="${options.name}"]`
18 | : `meta[property="${options.property}"]`
19 | )
20 | await expect(metaElement).toHaveAttribute('content', content)
21 | }
22 |
23 | /**
24 | * Retrieves all JSON-LD payloads from the page.
25 | */
26 |
27 | export async function getLdJsonPayloads(
28 | page: Page
29 | ): Promise> {
30 | const elements = await page
31 | .locator('script[type="application/ld+json"]')
32 | .all()
33 |
34 | return Promise.all(
35 | elements.map(async (element) => {
36 | const text = await element.textContent()
37 | return text ? JSON.parse(text) : null
38 | })
39 | )
40 | }
41 |
--------------------------------------------------------------------------------
/make-assets.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Make for assets
3 | tags: [Archived]
4 | archived: This sheet may be listing practices that are outdated.
5 | ---
6 |
7 | ### Basic compiling
8 |
9 | ```makefile
10 | bin := ./node_modules/.bin
11 |
12 | all: build/foo.js
13 |
14 | build/%.js: src/%.coffee
15 | @$(bin)/coffee < $^ > $@
16 | ```
17 |
18 | ### Stylus + Autoprefixer
19 |
20 | bin := ./node_modules/.bin
21 | stylus := $(bin)/stylus
22 | autoprefixer := $(bin)/autoprefixer
23 | styl_files := $(shell find web/ -name "*.styl")
24 |
25 | all: public/app.css
26 |
27 | public/app.css: css/app.styl
28 |
29 | %.css: %.styl $(styl_files)
30 | @$(stylus) $< | $(autoprefixer) -b "> 1%" > $@
31 |
32 | ### Hint
33 |
34 | hint:
35 | $(js_files)
36 |
37 | ### Watching
38 |
39 | watch:
40 | @echo "... watching for changes"
41 | @while true; do make -s; sleep 1; done
42 |
43 | ### Browserify
44 |
45 | js_files := $(shell find web/ -name "*.js")
46 |
47 | public/app.js: web/app.js
48 | public/vendor.js: web/vendor.js
49 |
50 | public/%.js: web/%.js $(js_files)
51 | $(browserify) -t [ cssify -x .css ] $< > $@
52 |
--------------------------------------------------------------------------------
/deis.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Deis
3 | category: Devops
4 | ---
5 |
6 | ### Deploy
7 |
8 | ```
9 | deis create app-name
10 | git push deis master
11 | deis open
12 | ```
13 |
14 | ### Deploy dockerfile
15 |
16 | ```sh
17 | $ deis create app-name
18 | $ deis pull redis:latest
19 | Creating build... done, v2
20 | # default process type is `cmd`
21 | ```
22 |
23 | ### Config
24 |
25 | ```
26 | deis config:list
27 | deis config:set FOO=bar BAZ=foo
28 | deis config:unset FOO
29 | deis config:pull # writes to .env
30 | deis config:push # reads from .env
31 | ```
32 |
33 | ### Managing instances
34 |
35 | ```
36 | deis logs
37 | deis run rake db:migrate
38 | deis ps
39 | ```
40 |
41 | ### Custom domains
42 |
43 | ```
44 | deis domains:list
45 | deis domains:add www.myapp.com
46 | deis domains:remove www.myapp.com
47 | ```
48 |
49 | ### Limits
50 |
51 | ```sh
52 | deis limits:set web=1G
53 | deis limits:set web=1024 --cpu
54 | # (`web` is a process type)
55 | ```
56 |
57 | ### Sharing
58 |
59 | ```
60 | deis perms:create otheruser
61 | ```
62 |
63 | ### SSL
64 |
65 | ```
66 | deis certs:add server.crt server.key
67 | ```
68 |
69 | See: [SSL](http://docs.deis.io/en/latest/using_deis/app-ssl/)
70 |
--------------------------------------------------------------------------------
/parsimmon.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Parsimmon
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Basic usage
7 | ```js
8 | const P = require('parsimmon')
9 |
10 | P.regexp(/[a-z]+/)
11 | .parse('hello')
12 | //=> { status: true, value: ['hello'] }
13 | ```
14 |
15 | ### Atoms
16 |
17 | ```js
18 | P.regexp(/[a-z]+/)
19 | P.string('hello')
20 | P.oneOf('abc') // like P.regexp(/[abc]/)
21 |
22 | P.whitespace
23 | P.optWhitespace
24 | P.eof
25 | ```
26 |
27 | ### Combinators
28 |
29 | ```js
30 | P.seq(a, b, c) // sequence of these
31 | P.alt(a, b) // any of these
32 | P.sepBy(a, P.string(',')) // sequence of `a`, separated by ','
33 | P.sepBy1(a, P.string(',')) // same, at least once
34 |
35 | a.or(b) // like P.alt(a, b)
36 | a.skip(b) // parses `b` but discards it
37 |
38 | a.many()
39 | a.times(3)
40 | a.times(1, 4) // 1 <= x <= 4
41 | a.atMost(10)
42 | a.atLeast(10)
43 | ```
44 |
45 | ### Formatting
46 |
47 | ```js
48 | P.seq(P.number, P.oneOf('+-*/'), P.number)
49 | .map(([left, oper, right]) => ({ oper, left, right }))
50 | ```
51 |
52 | ### Reference
53 |
54 | -
55 |
--------------------------------------------------------------------------------
/css-system-font-stack.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: "CSS system fonts"
3 | category: CSS
4 | weight: -3
5 | tags: [Featurable]
6 | ---
7 |
8 | ### System fonts
9 |
10 | ```css
11 | font-family: -apple-system, BlinkMacSystemFont,
12 | "Segoe UI", "Roboto", "Oxygen",
13 | "Ubuntu", "Cantarell", "Fira Sans",
14 | "Droid Sans", "Helvetica Neue", sans-serif;
15 | ```
16 |
17 | This uses whatever system font is available. See: [System shock - Designing Medium](https://medium.design/system-shock-6b1dc6d6596f?gi=90078e194544) _(medium.com)_
18 |
19 | ### Explanation
20 |
21 | | Font | OS |
22 | | ---- | -- |
23 | | `-apple-system` | OS X (10.11+), iOS (9+) |
24 | | `BlinkMacSystemFont` | OS X, Chrome |
25 | | `Segoe UI` | Windows |
26 | | `Roboto` | Android 4.0+ |
27 | | `Oxygen` | Linux, KDE |
28 | | `Ubuntu` | Linux, Ubuntu |
29 | | `Cantarell` | Linux, GNOME |
30 | | `Fira Sans` | Firefox OS |
31 | | `Droid Sans` | Android (until 3.2) |
32 | | `Helvetica Neue` | OS X (10.9) |
33 |
--------------------------------------------------------------------------------
/google_analytics.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Google Analytics
3 | tags: [Archived]
4 | archived: This sheet describes an older version of Google Analytics (UA).
5 | ---
6 |
7 | ### Pageview
8 |
9 | // Analytics.js
10 | ga('create', 'UA-XXXX-Y', 'auto');
11 | ga('send', 'pageview');
12 |
13 | ### Track events
14 |
15 | // ga.js
16 | // [..., category, action, label, value (int), noninteraction (bool)]
17 | _gaq.push(['_trackEvent', 'Videos', 'Play', 'Birthday video', true])
18 | _gaq.push(['_trackEvent', 'Projects', 'Donate', 'Project name'])
19 | _gaq.push(['_trackEvent', 'Accounts', 'Login'])
20 |
21 | // Analytics.js
22 | // , , category, action, label, value (int)
23 | ga('send', 'event', 'button', 'click', 'nav buttons', 4);
24 |
25 | ### Variables
26 |
27 | // [..., index, name, value, scope (optional)]
28 | _gaq.push(['_setCustomVar', 1, 'Logged in', 'Yes', 2]);
29 |
30 | // Scope = 1 (visitor), 2 (session), 3 (page, default)
31 |
32 | ### References
33 |
34 | -
35 | -
36 |
--------------------------------------------------------------------------------
/ledger-examples.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ledger examples
3 | category: Ledger
4 | ---
5 |
6 | ### Inspecting transactions
7 |
8 | # show me expenses for october (--period)
9 | ledger r Expenses -p oct
10 |
11 | # what's the most expensive? (--sorted)
12 | ledger r Expenses -S amount --tail 10
13 |
14 | # how much was spent on grocery? (--weekly, --monthly)
15 | ledger r Grocery
16 | ledger r Grocery -W
17 | ledger r Grocery -M
18 |
19 | # what did I spend my Mastercard on? (--period, --begin, --end)
20 | ledger r mastercard
21 | ledger r mastercard -p "january"
22 | ledger r mastercard -b 01/25 -e 01/31
23 |
24 | ### Graphing
25 |
26 | # Graph my bank account balance, monthly
27 | ledger r Savings -M
28 |
29 | # Graph my expenses, monthly (-n = --collapse)
30 | ledger r Expenses -M -n
31 |
32 | # ...what's the average per month?
33 | ledger r Expenses -M -n --average
34 |
35 | ### Simple
36 |
37 | # what did I do yesterday?
38 | # ..list transactions on this day
39 | ledger r -p 01/26
40 | ledger r -p yesterday
41 |
42 | ### Switches
43 |
44 | # what's everything I got in USD? (--exchange)
45 | ledger b Assets -X USD
46 |
--------------------------------------------------------------------------------
/clip.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Command Line Interface Pages
3 | category: CLI
4 | updated: 2023-02-23
5 | keywords:
6 | - CLI
7 | ---
8 |
9 | ### Page layout
10 |
11 | ```md
12 | # command
13 |
14 | > Some command description
15 | > More information: https://some/link/to/url
16 |
17 | - Some code description:
18 |
19 | `command argument1 argument2`
20 | ```
21 |
22 | ### [Primitive placeholders](https://github.com/command-line-interface-pages/syntax/blob/main/type-specific/cli.md#primitive-placeholders)
23 |
24 | ```md
25 | - Delay in [s]econds:
26 |
27 | `sleep {int seconds: 2}s`
28 | ```
29 |
30 | ### [Primitive repeated placeholders](https://github.com/command-line-interface-pages/syntax/blob/main/type-specific/cli.md#repeated-primitive-placeholders)
31 |
32 | ```md
33 | - [c]reate an archive and write it to a [f]ile:
34 |
35 | `tar {option mode: --create, -c} {option: --file, -f} {/?file archive: target.tar} {/?path+ input}`
36 | ```
37 |
38 | ### Also see
39 | {: .-one-column}
40 |
41 | * [Render](https://github.com/command-line-interface-pages/v2-tooling/tree/main/clip-view)
42 | * [Page's repository](https://github.com/command-line-interface-pages/cli-pages)
43 | * [Syntax](https://github.com/command-line-interface-pages/syntax/blob/main/base.md)
44 |
--------------------------------------------------------------------------------
/src/components/SEO/SEO.astro:
--------------------------------------------------------------------------------
1 | ---
2 | /*
3 | * Simplified replacement for astro-seo. Is less opinionated
4 | */
5 |
6 | export type Props = {
7 | title?: string
8 | meta?: Record
9 | metaProperties?: Record
10 | links?: Record
11 | }
12 |
13 | const props = Astro.props as Props
14 |
15 | function toArray(input: string | string[]): string[] {
16 | return (Array.isArray(input) ? input : [input]).filter(Boolean)
17 | }
18 | ---
19 |
20 | {props.title ? {props.title} : null}
21 |
22 | {
23 | props.meta
24 | ? Object.entries(props.meta).flatMap(([name, contents]) =>
25 | toArray(contents).map((content) => (
26 |
27 | ))
28 | )
29 | : null
30 | }
31 | {
32 | props.metaProperties
33 | ? Object.entries(props.metaProperties).flatMap(([property, contents]) =>
34 | toArray(contents).map((content) => (
35 |
36 | ))
37 | )
38 | : null
39 | }
40 | {
41 | props.links
42 | ? Object.entries(props.links).map(([rel, href]) => (
43 |
44 | ))
45 | : null
46 | }
47 |
--------------------------------------------------------------------------------
/jscoverage.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: jscoverage
3 | category: JavaScript libraries
4 | intro: |
5 | A small guide into installing [jscoverage](https://npmjs.com/package./jscoverage). Also see [mocha-blanket](./mocha-blanket).
6 | ---
7 |
8 | ### Install
9 |
10 | #### Install via npm
11 |
12 | ```bash
13 | npm install --save-dev jscoverage
14 | ```
15 |
16 | #### Ignore output
17 |
18 | ```bash
19 | echo coverage.html >> .gitignore
20 | ```
21 |
22 | ### package.json
23 |
24 | The `coverage` task injects your source files (`lib`) with jscoverage hooks, runs `mocha -R html-cov`, then restores later.
25 | {: .-setup}
26 |
27 | ```bash
28 | /* directory */
29 | "coverage": "mv lib lib~; (jscoverage lib~ lib; mocha -R html-cov > coverage.html); rm -rf lib; mv lib~ lib"
30 | ```
31 | {: .-hard-wrap}
32 |
33 | ```bash
34 | /* single file */
35 | "coverage": "(cp index.js index.js~; jscoverage index.js; mv index-cov.js index.js; mocha -R html-cov > coverage.html); mv index.js~ index.js"
36 | ```
37 | {: .-hard-wrap}
38 |
39 | ### Run
40 |
41 | ```bash
42 | npm run coverage
43 | ```
44 |
45 | ```bash
46 | open coverage.html
47 | ```
48 |
49 | ### Caveats
50 |
51 | If you're using jsdom, be sure to expose the `window._$jscoverage` variable into
52 | the `global` scope.
53 |
--------------------------------------------------------------------------------
/src/components/BaseLayout.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import 'hint.css'
3 | import '~/sass/full.scss'
4 | import '~/sass/2017/base/prism_line_highlight.scss'
5 |
6 | import '@fontsource/cousine/400.css'
7 | import '@fontsource/cousine/700.css'
8 | import '@fontsource/manrope/800.css'
9 | import GoogleAnalytics from '~/analytics/GoogleAnalytics.astro'
10 | import { googleAnalytics } from '~/config'
11 |
12 | export type Props = {
13 | title?: string
14 | bodyClass?: string
15 | }
16 |
17 | const props = Astro.props as Props
18 | const analyticsEnabled = googleAnalytics.enabled
19 | ---
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | {/* Title */}
28 | {props.title ? {props.title} : null}
29 | {/* Google tag */}
30 | {
31 | analyticsEnabled && googleAnalytics.measurementId ? (
32 |
33 | ) : null
34 | }
35 |
36 |
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/rst.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: ReStructuredText
3 | category: Markup
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | ReStructuredText is a markup language for writing documents.
10 |
11 | -
12 |
13 | ### Comments
14 |
15 | .. @theme 2010
16 | .. include:: ../themes/2010/common.rst
17 | .. contents::
18 | .. |substitute| replace:: replacement name
19 |
20 | ### Headings
21 |
22 | Heading
23 | =======
24 |
25 | .. class:: brief
26 |
27 | Hello there. |substitute| **This is bold**
28 |
29 |
30 | - Bullet list with a link_ (or `link with words`_)
31 | - Yes
32 |
33 | .. _link: http://link.org
34 |
35 | ### PDF page break
36 |
37 | .. raw:: pdf
38 |
39 | PageBreak oneColumn
40 |
41 | ### Link targets
42 |
43 | Internal link target_.
44 |
45 | .. _target:
46 |
47 | This is where _target will end up in.
48 |
49 | ### Tables (?)
50 |
51 | .. class:: hash-table
52 |
53 | .. list-table::
54 |
55 | * - :key:`Cuisine:`
56 | - :val:`French/fusion`
57 | * - :key:`Number of ingredients:`
58 | - :val:`8`
59 | * - :key:`Preparation time:`
60 | - :val:`30 hours`
61 |
--------------------------------------------------------------------------------
/web-workers.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Web workers
3 | category: JavaScript
4 | updated: 2017-10-30
5 | weight: -1
6 | ---
7 |
8 | ## Web workers
9 |
10 | #### Client
11 |
12 | ```js
13 | var worker = new Worker('worker.js')
14 |
15 | worker.onmessage = function (message) {
16 | alert(JSON.stringify(message.data))
17 | })
18 |
19 | worker.postMessage('hello!')
20 | ```
21 |
22 | Messages can be anything that can be serialized into JSON (objects, arrays, strings, numbers, booleans). See: [structured clone](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm)
23 |
24 | #### Worker
25 |
26 | ```js
27 | self.onmessage = function (message) {
28 | ···
29 | }
30 |
31 | self.postMessage({ msg: 'hello' })
32 | ```
33 |
34 | ### Message data
35 |
36 | #### [MessageEvent]
37 |
38 | ```js
39 | bubbles: false
40 | cancelBubble: false
41 | cancelable: false
42 | clipboardData: undefined
43 | currentTarget: Worker
44 | data: "Hello" ← the data
45 | defaultPrevented: false
46 | eventPhase: 0
47 | lastEventId: ""
48 | origin: ""
49 | ports: Array[0]
50 | returnValue: true
51 | source: null
52 | srcElement: Worker
53 | target: Worker
54 | timeStamp: 1344821022383
55 | type: "message"
56 | ```
57 |
58 | These are the contents of `message` on onmessage.
59 |
--------------------------------------------------------------------------------
/browserify.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Browserify
3 | category: JavaScript libraries
4 | tags: [Archived]
5 | archived: Browserify has not been in active development.
6 | ---
7 |
8 | ### About
9 | {: .-intro}
10 |
11 | Browserify is a bundler for JavaScript.
12 |
13 | -
14 |
15 | ### Usage
16 |
17 | browserify input.js
18 | -o output.js
19 | -t coffeeify
20 | -t [ coffeeify --extension coffee ]
21 |
22 | -u react (--exclude: omit a file)
23 | -x react (--external: reference in another bundle)
24 | -i react (--ignore: stub a file)
25 | -s Myapp (--standalone: generate a UMD bundle)
26 | --debug
27 |
28 | ### Programmatic usage
29 |
30 | browserify = require('browserify')
31 | browserify()
32 | .add('main.js')
33 | .bundle()
34 | .transform(coffeeify)
35 | .transform({extensions: '.coffee'}, coffeeify)
36 | .pipe(process.stdout)
37 |
38 | browserify({})
39 |
40 | ### Tools
41 |
42 | * watchify (recompiles on demand)
43 | * beefy (http server)
44 | * debowerify
45 | * es6ify (es6 to es5)
46 |
47 | Transforms
48 |
49 | * coffeeify
50 | * ractify
51 | * reactify
52 | * brfs
53 | * cssify
54 | * https://github.com/substack/node-browserify/wiki/list-of-transforms
55 |
56 |
--------------------------------------------------------------------------------
/imagemagick.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Imagemagick
3 | intro: |
4 | A quick reference for common [Imagemagick](https://www.imagemagick.org) commands and switches.
5 | ---
6 |
7 | ### Common options
8 |
9 | | Option | Description |
10 | | ------------------- | ------------------------------- |
11 | | `-resize 100x40` | Resize to a dimension |
12 | | `-crop 40x30+10+10` | (width)x(height)+(x)+y |
13 | | `-crop 40x30-10-10` | (width)x(height)+(x)+y |
14 | | `-flip` | Vertical |
15 | | `-flop` | Horizontal |
16 | | `-transpose` | Flip vertical + rotate 90deg |
17 | | `-transverse` | Flip horizontal + rotate 270deg |
18 | | `-trim` | Trim image edges |
19 | | `-rotate 90` | Rotate 90 degrees |
20 |
21 | ### Resize to fit
22 |
23 | ```sh
24 | convert input.jpg -resize 80x80^ -gravity center -extent 80x80 icon.png
25 | ```
26 |
27 | ### Convert all images to another format
28 |
29 | ```sh
30 | mogrify -format jpg -quality 85 *.png
31 | ```
32 |
33 | ### Make a pdf
34 |
35 | ```sh
36 | convert *.jpg hello.pdf
37 | ```
38 |
39 | ### References
40 |
41 | -
42 | -
43 |
--------------------------------------------------------------------------------
/ledger-format.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Ledger format
3 | category: Ledger
4 | ---
5 |
6 | ### Example
7 | ```
8 | 2015/01/01 Pay rent
9 | Assets:Savings -$300
10 | Expenses:Rent
11 | ```
12 |
13 | ### First line
14 |
15 | ```
16 | 2015/01/01 * Pay rent ; tagname:
17 | ^ ^ ^
18 | Date Flag Description ^ comment/tag
19 | ```
20 |
21 | ### Balance assertion
22 |
23 | ```
24 | 2015/01/01 Pay rent
25 | Assets:Savings -$300 = $1200 ; assert there's $1200 left after
26 | Expenses:Rent
27 | ```
28 | Flags:
29 |
30 | ```
31 | * cleared
32 | ! pending
33 | ```
34 |
35 | ## Accounts
36 |
37 | ### Accounts
38 |
39 | Only relevant with `--strict` or `--pedantic`
40 |
41 | ```
42 | account Expenses:Food
43 | note This account is all about the chicken!
44 | alias food
45 | payee ^(KFC|Popeyes)$
46 | check commodity == "$"
47 | assert commodity == "$"
48 | eval print("Hello!")
49 | default
50 | ```
51 |
52 | ## Others
53 |
54 | ### Others
55 |
56 | ```
57 | D $1,000.00 ; set default commodity
58 |
59 | alias Cash = Assets:Cash
60 |
61 | Y2015 ; set default year (you can use 01/25 as date after)
62 | ```
63 |
64 | ### Prefix all transactions with an account
65 |
66 | ```
67 | account Home
68 | include home.journal
69 | end
70 | ```
71 |
--------------------------------------------------------------------------------
/machinist.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Machinist
3 | category: Ruby libraries
4 | tags: [Archived]
5 | archived: Machinist has not been in active development since 2013.
6 | ---
7 |
8 | ### About
9 |
10 | Machinist is a fixture management library for Ruby.
11 |
12 | -
13 |
14 | ### Installing
15 |
16 | # Gemfile
17 | gem 'machinist', '>= 2.0.0.beta2', group: 'test'
18 |
19 | # ~$ bundle
20 | # ~$ rails generate machinist:install
21 |
22 | ### Building objects
23 |
24 | User.make
25 |
26 | # `make` builds it, and `make!` builds+saves it
27 | User.make!
28 | User.make! name: "David"
29 | User.make!(:admin)
30 |
31 | ### Defining blueprints
32 |
33 | User.blueprint do
34 | name { "User #{sn}" }
35 | email { "user-#{sn}@example.com" }
36 | end
37 |
38 | User.blueprint(:admin) do
39 | name { "Admin User #{sn}" }
40 | admin { true }
41 | end
42 |
43 | ### Associations
44 |
45 | Post.blueprint do
46 | author { User.make }
47 |
48 | comments(3) # Makes 3 comments (has_many / habtm)
49 |
50 | author # autodetect (Assumes there's User.blueprint)
51 |
52 | end
53 |
54 | ### References
55 |
56 | * [https://github.com/notahat/machinist](https://github.com/notahat/machinist)
57 |
--------------------------------------------------------------------------------
/AGENTS.md:
--------------------------------------------------------------------------------
1 | # Agent guidelines for devhints.io
2 |
3 | ## Commands
4 |
5 | - **Dev server**: `pnpm dev` (requires Ruby for markdown caching)
6 | - **Build**: `pnpm build`
7 | - **Test**: `pnpm test` (runs Vitest in watch mode)
8 | - **Run single test**: `pnpm vitest run ` or `pnpm vitest ` (watch mode)
9 | - **All tests (CI)**: `pnpm ci` (runs all linters, tests, and build)
10 | - **Lint**: `pnpm eslint:check` or `pnpm prettier:check`
11 | - **Format**: `pnpm format` (runs both ESLint and Prettier fixes)
12 |
13 | ## Code style
14 |
15 | - **Package manager**: pnpm (v8.15.4+)
16 | - **Framework**: Astro with TypeScript (strict mode), Tailwind CSS
17 | - **Imports**: Use `~/` alias for `src/` directory; Prettier organizes imports automatically
18 | - **Types**: Use Zod schemas for runtime validation (see `SheetFrontmatter.ts`); TypeScript strict mode enabled
19 | - **Naming**: camelCase for variables/functions, PascalCase for components/types
20 | - **Error handling**: Distinguish operational (expected) vs unexpected errors; return error objects for operational errors
21 | - **Testing**: Vitest with globals enabled; use `it.each()` for repeated test cases; prefer object constants over helper functions
22 |
23 | ## Markdown files
24 |
25 | Consult @_docs/writing-guidelines.md for formatting *.md files.
26 |
--------------------------------------------------------------------------------
/c_preprocessor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: C Preprocessor
3 | category: C-like
4 | intro: |
5 | Quick reference for the [C macro preprocessor](https://en.m.wikipedia.org/wiki/C_preprocessor), which can be used independent of C/C++.
6 | ---
7 |
8 | ## Reference
9 | {: .-three-column}
10 |
11 | ### Compiling
12 |
13 | ```
14 | $ cpp -P file > outfile
15 | ```
16 |
17 | ### Includes
18 |
19 | ```
20 | #include "file"
21 | ```
22 |
23 | ### Defines
24 |
25 | ```
26 | #define FOO
27 | #define FOO "hello"
28 |
29 | #undef FOO
30 | ```
31 |
32 | ### If
33 |
34 | ```
35 | #ifdef DEBUG
36 | console.log('hi');
37 | #elif defined VERBOSE
38 | ...
39 | #else
40 | ...
41 | #endif
42 | ```
43 |
44 | ### Error
45 |
46 | ```
47 | #if VERSION == 2.0
48 | #error Unsupported
49 | #warning Not really supported
50 | #endif
51 | ```
52 |
53 | ### Macro
54 |
55 | ```
56 | #define DEG(x) ((x) * 57.29)
57 | ```
58 |
59 | ### Token concat
60 |
61 | ```
62 | #define DST(name) name##_s name##_t
63 | DST(object); #=> object_s object_t;
64 | ```
65 |
66 | ### Stringification
67 |
68 | ```
69 | #define STR(name) #name
70 | char * a = STR(object); #=> char * a = "object";
71 | ```
72 |
73 | ### file and line
74 |
75 | ```
76 | #define LOG(msg) console.log(__FILE__, __LINE__, msg)
77 | #=> console.log("file.txt", 3, "hey")
78 | ```
79 |
--------------------------------------------------------------------------------
/src/sass/2017/components/main-heading.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * The top-level heading
3 | */
4 |
5 | .main-heading {
6 | @include heading-style;
7 |
8 | & {
9 | margin-top: 0;
10 | margin-bottom: 0;
11 | }
12 |
13 | & > h1 {
14 | @include font-size(8);
15 | line-height: 1.2;
16 | font-weight: 200;
17 | font-family: $body-font;
18 | margin: 0;
19 | text-align: center;
20 | }
21 |
22 | & > h1 > em {
23 | font-style: normal;
24 | color: lighten($gray-text, 20%);
25 | }
26 |
27 | & > .pubbox {
28 | margin-top: 16px;
29 | text-align: center;
30 | }
31 |
32 | @media (min-width: 769px) {
33 | & > .pubbox {
34 | margin-top: 24px;
35 | margin-bottom: 24px;
36 | }
37 | }
38 | }
39 |
40 | .UseCompactHeader .main-heading {
41 | @media (min-width: 769px) {
42 | & {
43 | display: flex;
44 | align-items: flex-end;
45 | margin-bottom: 32px;
46 | }
47 |
48 | & > h1 {
49 | flex: 1 0 auto;
50 | text-align: left;
51 | padding-right: 32px;
52 | }
53 |
54 | & > .pubbox {
55 | flex: 0 0 auto;
56 | margin-top: 0;
57 | margin-bottom: 0;
58 | }
59 | }
60 | }
61 |
62 | /**
63 | * Add some space in preview mode
64 | */
65 |
66 | .PreviewMode .main-heading {
67 | margin-top: 16px;
68 | }
69 |
--------------------------------------------------------------------------------
/.github/workflows/build.yml:
--------------------------------------------------------------------------------
1 | name: Run tests
2 | on:
3 | push:
4 | branches: [main, master]
5 | pull_request:
6 | branches: [main, master]
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v4
12 | - uses: ruby/setup-ruby@v1
13 | with:
14 | bundler-cache: true
15 | - uses: actions/setup-node@v4
16 | with:
17 | node-version-file: .node-version
18 | - uses: pnpm/action-setup@v3
19 | with: { run_install: false }
20 |
21 | # https://github.com/pnpm/action-setup?tab=readme-ov-file#use-cache-to-reduce-installation-time
22 | - name: Get pnpm store directory
23 | shell: bash
24 | run: |
25 | echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
26 | - uses: actions/cache@v4
27 | name: Setup pnpm cache
28 | with:
29 | path: ${{ env.STORE_PATH }}
30 | key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
31 | restore-keys: |
32 | ${{ runner.os }}-pnpm-store-
33 |
34 | - name: Install dependencies
35 | run: pnpm install --frozen-lockfile
36 | - name: Install playwright browsers
37 | run: pnpm playwright install --with-deps chromium
38 | - name: Run tests
39 | run: pnpm run ci
40 |
--------------------------------------------------------------------------------
/bundler.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bundler
3 | category: Ruby
4 | ---
5 |
6 | ### Commands
7 |
8 | bundle # same as bundle install
9 | bundle install # installs gems
10 | bundle install -j3 # faster (3 jobs)
11 | bundle update # update all gems
12 | bundle update --source gemname # update specified gem
13 |
14 | bundle outdated # show outdated gems
15 | cd `bundle show rails` # inspect a gem's dir
16 |
17 | bundle gem # new gem skeleton
18 |
19 | ### Gems
20 |
21 | gem 'hello'
22 | gem 'hello', group: 'development'
23 |
24 | ### Github support
25 |
26 | gem 'hello', github: 'rstacruz/hello'
27 | gem 'hello', github: 'rstacruz/hello', 'branch: master'
28 |
29 | ### Grouping
30 |
31 | group :development do
32 | gem 'hello'
33 | end
34 |
35 | ### Deployment
36 |
37 | $ bundle install --without=test,development --deployment
38 |
39 | ### Local gem development
40 |
41 | In your Gemfile, define a Git source and a branch:
42 |
43 | gem 'hello', github: 'rstacruz/hello', branch: 'master'
44 |
45 | And then:
46 |
47 | $ bundle config --global local.xxx ~/projects/xxx
48 |
49 | ### Rake Gem tasks
50 |
51 | # Rakefile
52 | require 'bundler/gem_tasks'
53 |
54 | Terminal:
55 |
56 | $ rake release
57 | $ rake build
58 |
--------------------------------------------------------------------------------
/src/sass/2017/components/related-posts-callout.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Callout
3 | */
4 |
5 | .related-posts-callout {
6 | & {
7 | display: flex;
8 | text-decoration: none;
9 | background: $base-a-gradient;
10 | padding: 32px;
11 | align-items: center;
12 | justify-content: center;
13 | color: white;
14 | border-radius: 2px;
15 | box-shadow: $shadow2;
16 | text-shadow: 0 1px 1px rgba(black, 0.2);
17 | }
18 |
19 | &,
20 | &:visited {
21 | color: white;
22 | }
23 |
24 | &:hover,
25 | &:focus {
26 | background: darken($base-a, 8%);
27 | }
28 |
29 | & > .text {
30 | margin: auto;
31 | text-align: center;
32 | }
33 |
34 | & > .text > .icon {
35 | margin-bottom: 16px;
36 | display: block;
37 | }
38 |
39 | & > .text > .icon::before {
40 | content: '';
41 | @include ion-ios-arrow-back(
42 | 48px,
43 | adjust-color($base-a, $lightness: 16%, $hue: 20deg)
44 | );
45 | height: 64px;
46 | width: 64px;
47 | border: solid 2px adjust-color($base-a, $lightness: 16%, $hue: 20deg);
48 | border-radius: 50%;
49 | text-indent: -2px;
50 | text-shadow: none;
51 | }
52 |
53 | & > .text > .description {
54 | @include font-size(1);
55 | line-height: 1.4;
56 | font-weight: 300;
57 | display: block;
58 | margin-bottom: 16px;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/nodejs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Node.js API
3 | category: Node.js
4 | ---
5 |
6 | ### Globals
7 |
8 | __filename
9 | __dirname
10 |
11 | ### exec
12 |
13 | var exec = require('child_process').exec,
14 |
15 | var child = exec('cat *.js bad_file | wc -l',
16 | function (error, stdout, stderr) {
17 | console.log('stdout: ' + stdout);
18 | console.log('stderr: ' + stderr);
19 | if (error !== null) {
20 | console.log('exec error: ' + error);
21 | }
22 | });
23 |
24 | ### Snippets
25 |
26 | info = require('../package.json')
27 | info.version
28 |
29 | process.stdout.write(util.inspect(objekt, false, Infinity, true) + '\n');
30 |
31 | ### Spawn - passthru the in/out
32 |
33 | var spawn = require('child_process').spawn;
34 | var proc = spawn(bin, argv, { stdio: 'inherit' });
35 | proc.on('error', function(err) {
36 | if (err.code == "ENOENT") { "does not exist" }
37 | if (err.code == "EACCES") { "not executable" }
38 | });
39 | proc.on('exit', function(code) { ... });
40 |
41 | // also { stdio: ['pipe', 'pipe', process.stdout] }
42 | // also { stdio: [process.stdin, process.stderr, process.stdout] }
43 |
44 | proc.stdout.on('data', function (data) {
45 | });
46 | proc.stderr.on('data', function (data) {
47 | });
48 |
49 | [all]: http://nodejs.org/api/all.html
50 |
--------------------------------------------------------------------------------
/meow.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Meow
3 | category: JavaScript libraries
4 | updated: 2017-10-30
5 | weight: -1
6 | intro: |
7 | [meow](https://npmjs.com/package/meow) is the easiest way to write command line apps for Node.js.
8 | ---
9 |
10 | ### Typical settings
11 |
12 | ```js
13 | const cli = require('meow')(`
14 | Usage: appname [options]
15 |
16 | Options:
17 | --lang LANG set the language
18 |
19 | Other options:
20 | -h, --help show usage information
21 | -v, --version print version info and exit
22 | `, {
23 | string: ['lang'],
24 | boolean: ['help', 'version'],
25 | alias: { h: 'help', v: 'version' }
26 | })
27 | ```
28 |
29 | `string` and `boolean` lets meow/minimist know which flags expect arguments (`string`) and which don't (`boolean`).
30 |
31 | ### Using the result
32 |
33 | ```js
34 | cli.flags // { lang: 'en' }
35 | cli.input // []
36 | ```
37 |
38 | Yes, flags are automatically camelCased!
39 |
40 | ### Lesser-used settings
41 |
42 | ```js
43 | meow(`...`, {
44 | // Default values if flags are not specified
45 | default: { lang: 'en' },
46 |
47 | // allow using -- to stop processing flags
48 | '--': true,
49 |
50 | // Populate `_` with first non-option
51 | stopEarly: true,
52 |
53 | // Invoked on unknown param
54 | unknown: function () { ... }
55 | })
56 | ```
57 |
58 | Also see [minimist](minimist.html).
59 |
--------------------------------------------------------------------------------
/src/ruby/renderer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Renders Markdown to HTML, emulating Jekyll 2 quirks.
4 | module Renderer
5 | module_function
6 |
7 | KRAMDOWN_OPTIONS = {
8 | input: 'GFM',
9 | hard_wrap: false
10 | }.freeze
11 |
12 | def render(input:)
13 | require 'kramdown'
14 |
15 | new_input = input.to_s
16 | .gsub(/^{% ?raw ?%}\n/, '') # raw on its own line
17 | .gsub(/{% ?raw ?%}/, '') # inline in another line
18 | .gsub(/{% include (common\/[^ ]+) title="([^"]+)" %}/) {
19 | # a reduced subset of Jekyll includes
20 | title = $2
21 | file = $1
22 | filepath = Pathname.new("_includes/#{file}").cleanpath.to_s
23 |
24 | if filepath.start_with?("/") || filepath.start_with?(".")
25 | raise Errno::ENOENT, "Invalid include - #{filepath}"
26 | end
27 |
28 | if !File.exist?(filepath)
29 | raise Errno::ENOENT, "Cannot find include - #{filepath}"
30 | end
31 |
32 | data = File.read(filepath)
33 | data = data.gsub(/{{ include.title }}/m, title)
34 | data
35 | }
36 | .gsub(/^{% ?endraw ?%}\n/, '')
37 | .gsub(/{% ?endraw ?%}/, '')
38 | .gsub(/ {%- if 0 -%}{%- endif -%} /, '') # Used in jinja.md
39 | .gsub(/{%- raw -%}\n?/, '') # Used in jinja.md
40 | Kramdown::Document.new(new_input, KRAMDOWN_OPTIONS).to_html
41 | end
42 | end
43 |
--------------------------------------------------------------------------------
/src/pages/404.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import cx from 'clsx'
3 | import BaseLayout from '~/components/BaseLayout.astro'
4 | import TopNav from '~/components/TopNav.astro'
5 | import SearchForm from '~/components/V2017Sheet/SearchForm.astro'
6 |
7 | const t = {
8 | title: '404',
9 | description: "Sorry, we don't have a cheatsheet for this yet. Try searching!",
10 | goHome: 'Back to home'
11 | }
12 |
13 | const styles = {
14 | body: 'V2017Sheet__body max-w-slim p-6 md:px-8 mx-auto'
15 | }
16 |
17 | const headingStyles = {
18 | root: cx('SiteHeading404__root', 'my-12 mt-[30svh] text-center'),
19 | h1: cx('SiteHeading404__h1', `text-5xl font-bold`),
20 | tagline: cx('SiteHeading404__tagline', 'mt-4', 'text-2xl')
21 | }
22 | ---
23 |
24 |
25 |
26 |
27 |
28 |
{t.title}
29 |
{t.description}
30 |
31 |
38 |
39 |
40 |
41 |
46 |
--------------------------------------------------------------------------------
/js-model.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: js-model
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Example
7 |
8 | ```bash
9 | Project = Model "project", ->
10 | @extend
11 | findByTitle: (title) -> ...
12 |
13 | @include
14 | markAsDone: -> ...
15 |
16 | # ActiveRecord::Base.include_root_in_json = false
17 | ```
18 |
19 | ```bash
20 | project = Project.find(1)
21 | project = Project.findByTitle("hello")
22 |
23 | project.markAsDone()
24 | ```
25 |
26 | ### Persistence
27 |
28 | ```bash
29 | Project "hi", ->
30 | @persistence Model.REST, "/projects"
31 | @persistence Model.localStorage
32 | ```
33 |
34 | ```bash
35 | Project.load ->
36 | # loaded
37 | ```
38 |
39 | ### Attrs
40 |
41 | ```bash
42 | project = new Project(name: "Hello")
43 |
44 | project.attr('name', "Hey")
45 | project.attr('name')
46 |
47 | project.save()
48 | project.destroy()
49 | ```
50 |
51 | ### Collection
52 |
53 | ```bash
54 | Food.add(egg)
55 | Food.all()
56 | Food.select (food) -> ...
57 | Food.first()
58 | ```
59 |
60 | ```bash
61 | Food.find(id)
62 | ```
63 |
64 | ### Events
65 |
66 | ```bash
67 | # Classes
68 | Project.bind "add", (obj) ->
69 | Project.bind "remove", (obj) ->
70 | ```
71 |
72 | ```bash
73 | # Instances
74 | project.bind "update", ->
75 | project.bind "destroy", ->
76 | ```
77 |
78 | ```bash
79 | project.trigger "turn_blue"
80 | ```
81 |
82 | ## References
83 | {: .-one-column}
84 |
85 | -
86 |
--------------------------------------------------------------------------------
/src/sass/2017/components/pages-list.scss:
--------------------------------------------------------------------------------
1 | // search-box.scss
2 |
3 | .pages-list {
4 | & {
5 | display: flex;
6 | flex-wrap: wrap;
7 | }
8 |
9 | > .item {
10 | flex: 0 0 100%;
11 | }
12 |
13 | > .item.article {
14 | flex: 0 0 50%;
15 | }
16 |
17 | @media (min-width: 581px) {
18 | > .item.top-sheet {
19 | flex: 0 0 25%;
20 | }
21 | }
22 | }
23 |
24 | // Article
25 | .pages-list > .article {
26 | text-decoration: none;
27 | display: block;
28 | white-space: nowrap;
29 | padding: 4px 0;
30 |
31 | &,
32 | &:visited {
33 | color: $base-mute3;
34 | }
35 |
36 | & > .info > .slug {
37 | color: $base-head;
38 | }
39 |
40 | &:visited > .info > .slug {
41 | color: $base-text;
42 | }
43 |
44 | & > .info > .title::before {
45 | content: '';
46 | margin: 0 4px;
47 | }
48 |
49 | & > .info > .title {
50 | opacity: 0;
51 | }
52 |
53 | @media (max-width: 768px) {
54 | & > .info > .title {
55 | display: none;
56 | }
57 | }
58 |
59 | &:hover,
60 | &:focus {
61 | & {
62 | color: $base-mute;
63 | }
64 |
65 | & > .info > .title {
66 | opacity: 1;
67 | color: $base-a;
68 | }
69 | }
70 | }
71 |
72 | .pages-list > .category {
73 | @include font-size(1);
74 | border-bottom: solid 1px $dark-line-color;
75 | margin: 16px 0;
76 | padding: 0 0 16px 0;
77 | font-weight: normal;
78 | color: $base-a;
79 | }
80 |
--------------------------------------------------------------------------------
/src/sass/2017/components/related-posts-section.scss:
--------------------------------------------------------------------------------
1 | /*
2 | * Section
3 | * has callout and group
4 | */
5 |
6 | .related-posts-section {
7 | & {
8 | display: flex;
9 | @include section-gutter(margin-left, $multiplier: -1);
10 | @include section-gutter(margin-right, $multiplier: -1);
11 | }
12 |
13 | & > .callout,
14 | & > .group {
15 | margin: 0;
16 | @include section-gutter(margin-left);
17 | @include section-gutter(margin-right);
18 | }
19 |
20 | & > .callout {
21 | flex: 1 1 33%;
22 | }
23 |
24 | & > .group {
25 | flex: 1 1 50%;
26 | }
27 |
28 | & > .callout {
29 | display: flex;
30 |
31 | & > * {
32 | flex: 1 0 100%;
33 | }
34 | }
35 |
36 | // Mobile
37 | @media (max-width: 480px) {
38 | & {
39 | flex-wrap: wrap;
40 | }
41 |
42 | & > .callout,
43 | & > .group {
44 | @include section-gutter(margin-top);
45 | @include section-gutter(margin-bottom);
46 | flex: 1 1 100%;
47 | }
48 | }
49 |
50 | // Tablet
51 | @media (min-width: 481px) {
52 | @media (max-width: 768px) {
53 | & {
54 | flex-wrap: wrap;
55 | }
56 |
57 | & > .callout,
58 | & > .group {
59 | @include section-gutter(margin-top);
60 | @include section-gutter(margin-bottom);
61 | flex: 1 1 100%;
62 | }
63 |
64 | & > .group {
65 | flex: 1 1 40%;
66 | }
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/weechat.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Weechat
3 | category: Apps
4 | ---
5 |
6 | ## Keys
7 | {: .-three-column}
8 |
9 | ### Buffers
10 |
11 | | Shortcut | Description |
12 | | --- | --- |
13 | | `^s` / `^u` | Set unread marker on all windows |
14 | | --- | --- |
15 | | `^p, A-left` | Switch buffer left |
16 | | `^n, A-right` | Switch buffer right |
17 | | `A-a` | Next buffer with activity |
18 | | `A-0...9` | Switch buffers |
19 | | --- | --- |
20 | | `F9` /` F10` | Scroll buffer title |
21 | | `F11` / `F12` | Scroll nick list |
22 | | --- | --- |
23 | | `A-w A-Left` | Switch windows |
24 | | `A-w A-b` | Balance windows |
25 | {: .-shortcuts}
26 |
27 | (`A-` is alt.)
28 |
29 | ### Window commands
30 |
31 | | Shortcut | Description |
32 | | --- | --- |
33 | | `/window splith` | Split horizontal |
34 | | `/window splitv` | Split vertical |
35 | | `/window zoom` | Zoom |
36 |
37 | ### Search
38 |
39 | | `^r` | Search |
40 | | `Enter` `^j` `^m` | Stop search |
41 | {: .-shortcuts}
42 |
--------------------------------------------------------------------------------
/deku.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Deku v2
3 | category: JavaScript libraries
4 | intro: |
5 | Quick reference for [Deku](https://www.npmjs.com/package/deku), a minimal virtual DOM library.
6 | ---
7 |
8 | ### Components
9 |
10 | ```js
11 | /** @jsx element */
12 | import { element } from 'deku'
13 |
14 | function render ({ props, children, context, path }) {
15 | // props = properties object
16 | // children = children array
17 | // path = path to current component (like 0.1.5.2)
18 | // context = common properties in all components
19 | return (
20 |
21 | {children}
22 |
23 | }
24 | }
25 |
26 | function onCreate ({ props, dispatch, path }) { ... }
27 | function onUpdate ({ props, dispatch, path }) { ... }
28 | function onRemove ({ props, dispatch, path }) { ... }
29 | // actually { children, props, path, context }
30 |
31 | export default { render, onCreate, onRemove }
32 | ```
33 |
34 | ### Rendering
35 |
36 | ```js
37 | import { createStore } from 'redux'
38 | import { dom, element } from 'deku'
39 |
40 | // Create a Redux store to handle all UI actions and side-effects
41 | let store = createStore(reducer)
42 |
43 | // Create a renderer that can turn vnodes into real DOM elements
44 | let render = createRenderer(document.body, store.dispatch)
45 |
46 | // Update the page and add redux state to the context
47 | render(Hello World!, store.getState())
48 | ```
49 |
--------------------------------------------------------------------------------
/tomdoc.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Tomdoc
3 | category: Markup
4 | ---
5 |
6 | ### Tomdoc
7 | {: .-prime}
8 |
9 | ```ruby
10 | # Public: Duplicate some text an arbitrary number of times.
11 | #
12 | # text - The String to be duplicated.
13 | # count - The Integer number of times to duplicate the text.
14 | #
15 | # Examples
16 | #
17 | # multiplex('Tom', 4)
18 | # # => 'TomTomTomTom'
19 | #
20 | # Returns the duplicated String.
21 | def multiplex(text, count)
22 | text * count
23 | end
24 | ```
25 |
26 | See [tomdoc.org](http://tomdoc.org/).
27 |
28 | ### Tags
29 |
30 | - `Deprecated`
31 | - `Internal`
32 | - `Public`
33 |
34 | ### Options
35 |
36 | ```ruby
37 | # options - The Hash options used to refine the selection (default: {}):
38 | # :color - The String color to restrict by (optional).
39 | # :weight - The Float weight to restrict by. The weight should
40 | # be specified in grams (optional).
41 | ```
42 |
43 | ### Yields
44 |
45 | ```ruby
46 | # Yields the Integer index of the iteration.
47 | ```
48 |
49 | ```ruby
50 | # Returns the duplicated String.
51 | ```
52 |
53 | ```ruby
54 | # Returns nothing.
55 | ```
56 |
57 | ```ruby
58 | # Raises Errno::ENOENT if the file can't be found.
59 | ```
60 |
61 | ```ruby
62 | # Returns something else and this is a wrapped
63 | # multi-line comment.
64 | ```
65 |
66 | ### Signatures
67 |
68 | ```ruby
69 | # Signature
70 | #
71 | # find_by_[_and_...](args)
72 | #
73 | ```
74 |
--------------------------------------------------------------------------------
/mocha-blanket.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Mocha blanket
3 | category: JavaScript libraries
4 | intro: |
5 | Use [blanket](https://npmjs.com/package/blanket) for easy coverage reporting for Mocha JavaScript tests.
6 | ---
7 |
8 | ### Quickstart guide
9 |
10 | Install blanket:
11 | {: .-setup}
12 |
13 | ```bash
14 | npm i --save-dev blanket
15 | ```
16 |
17 | In your test helpers, use Blanket before `require`ing:
18 |
19 | ```js
20 | if (process.env.COVERAGE) {
21 | require('blanket')({
22 | pattern: require('path').resolve('./index.js')
23 | });
24 | }
25 | thing = require('../index');
26 | ```
27 |
28 | Add to `package.json`:
29 |
30 | ```json
31 | "scripts": {
32 | "coverage": "env COVERAGE=1 mocha -R html-cov > coverage.html && open coverage.html"
33 | }
34 | ```
35 |
36 | Be sure to ignore it:
37 |
38 | ```bash
39 | echo "coverage.html" >> .gitignore
40 | ```
41 |
42 | Then run:
43 |
44 | ```bash
45 | npm run coverage
46 | ```
47 |
48 | ### Travis + coveralls.io support
49 |
50 | Visit [coveralls.io] then activate your repo. Then install the appropriate packages:
51 | {: .-setup}
52 |
53 | ```bash
54 | npm i --save-dev mocha-lcov-reporter coveralls
55 | ```
56 |
57 | Add this to `.travis.yml`:
58 |
59 | ```yml
60 | after_success:
61 | - ./node_modules/.bin/mocha -R mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
62 | ```
63 |
64 | Commit, push, wait for Travis to finish.
65 |
66 | [blanket]: https://www.npmjs.org/package/blanket
67 | [coveralls.io]: http://coveralls.io
68 |
--------------------------------------------------------------------------------
/watchexec.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Watchexec
3 | updated: 2017-10-18
4 | category: CLI
5 | weight: -1
6 | keywords:
7 | - "watchexec --excts js,jsx -- npm test"
8 | - "watchexec --help"
9 | intro: |
10 | [mattgreen/watchexec](https://github.com/mattgreen/watchexec) runs commands whenever certain files change.
11 | ---
12 |
13 | ### Installation
14 |
15 | #### OSX
16 |
17 | ```bash
18 | brew install watchexec
19 | ```
20 |
21 | #### Rust
22 |
23 | ```bash
24 | cargo install watchexec
25 | ```
26 |
27 | For Linux and Windows, get it from [GitHub releases](https://github.com/mattgreen/watchexec).
28 |
29 | ### Getting started
30 |
31 | ```bash
32 | watchexec --exts js,jsx -- npm test
33 | ```
34 |
35 | Runs `npm test` when `js,jsx` files change.
36 |
37 | ```bash
38 | watchman -w lib -w test -- npm test
39 | ```
40 |
41 | Runs `npm test` when `lib/` and `test/` files change.
42 |
43 | ### Other options
44 |
45 | #### Flags
46 |
47 | | `-c` `--clear` | Clear screen |
48 | | `-r` `--restart` | Restart process if its still running |
49 |
50 | #### Options
51 |
52 | | `-s` `--signal SIGKILL` | Kill signal to use |
53 | | `-d` `--debounce MS` | Debounce by `MS` milliseconds |
54 | | `-e` `--exts EXTS` | Extensions |
55 | | `-i` `--ignore PATTERN` | Ignore these files |
56 | | `-w` `--watch PATH` | Watch these directories |
57 |
58 | ## Also see
59 |
60 | * [mattgreen/watchexec](https://github.com/mattgreen/watchexec) _(github.com)_
61 |
--------------------------------------------------------------------------------
/dom-range.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: DOM Range
3 | category: JavaScript
4 | intro: |
5 | Quick reference to the HTML [DOM createRange API](https://devdocs.io/dom/range).
6 | ---
7 |
8 | ## Reference
9 | {:.-three-column}
10 |
11 | ### Creating ranges
12 |
13 | ```js
14 | var range = document.createRange()
15 | ```
16 |
17 | See:
18 |
19 | ## Methods
20 |
21 | ```js
22 | range
23 | .setStart(startNode, startOffset)
24 | .setEnd(endNode, endOffset)
25 |
26 | .setStartBefore(node)
27 | .setStartAfter(node)
28 | .setEndBefore(node)
29 | .setEndAfter(node)
30 |
31 | .selectNode(node)
32 | .selectNodeContents(node)
33 | ```
34 |
35 | See:
36 |
37 | ### Collapsing
38 |
39 | ```js
40 | range.collapse() // to end (a single point)
41 | range.collapse(true) // to start (a single point)
42 | range.collapsed // true | false
43 | ```
44 |
45 | ### Operations
46 |
47 | ```js
48 | range.cloneContents() // copy => DocumentFragment
49 | range.extractContents() // cut => DocumentFragment
50 | range.deleteContents() // delete
51 | ```
52 |
53 | ```js
54 | range.insertNode(node)
55 | ```
56 |
57 | ### String
58 |
59 | ```js
60 | range.toString()
61 | ```
62 |
63 | ### Read-only attributes
64 |
65 | ```js
66 | range.collapsed // => true/false
67 | range.startContainer // => Node
68 | range.startOffset
69 | range.endContainer // => Node
70 | range.endOffset
71 | range.commonAncestorContainer // closest of start and end containers
72 | ```
73 |
--------------------------------------------------------------------------------
/linux.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Linux
3 | ---
4 |
5 | ### Read/Write/Execute a file
6 |
7 | $ chmod +rwx App
8 | $ ./App
9 |
10 | ### Remove
11 |
12 | $ rm namefile
13 | $ rm -d Directory
14 | $ rm -rf Directory_with_files
15 |
16 | ### Copy file to a folder
17 |
18 | $ cp namefile Downloads
19 | $ ls
20 | namefile Desktop Documents Downloads Music Pictures Public Templates Videos
21 | $ cd Downloads
22 | ~/Downloads$ ls
23 | namefile
24 |
25 |
26 | ### Create empty file
27 |
28 | $ touch namefile
29 | $ touch --help
30 |
31 | ### Show in the terminal the file
32 |
33 | $ cat namefile
34 | $ cat --help
35 |
36 |
37 | ### Create new directory
38 |
39 | $ mkdir name
40 | $ mkdir --help
41 |
42 | ### list files from directory
43 |
44 | $ ls
45 | Desktop Documents Downloads Music Pictures Public Templates Videos
46 | $ ls --help
47 |
48 | ### Mounting a RAM drive
49 |
50 | $ mount -t tmpfs -o size=5G,nr_inodes=5k,mode=700 tmpfs /tmp
51 |
52 | ### Visudo
53 |
54 | sudo visudo
55 |
56 | username ALL=(ALL) NOPASSWD:/sbin/restart whatever
57 |
58 | ### Display the amount of available disk space
59 |
60 | ```sh
61 | df
62 | df -h # human-readable format
63 | df -a # all filesystems
64 | ```
65 |
66 | ### Display disk usage
67 |
68 | ```sh
69 | du
70 | du -hsx * | sort -rh | head -10 # largest 10 folders
71 | ```
72 |
73 | ### Answer yes in a bash script
74 |
75 | ```bash
76 | yes | /your/command
77 | ```
78 |
--------------------------------------------------------------------------------
/nodejs-fs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: fs
3 | category: Node.js
4 | ---
5 |
6 | ### Reading
7 |
8 | fs.readFile('file.txt', function(err, data) { .. });
9 | fs.readFile('file.txt', {encoding: 'utf-8'}, function(err, data) { .. });
10 |
11 | ### Writing
12 |
13 | fs.writeFile('output.txt', function(err) { .. });
14 | fs.appendFile('output.txt', function(err) { .. });
15 |
16 | ### Watch
17 |
18 | fs.watch('dir OR file.txt', { persistent: true }, function(event, file) {
19 | event; /* rename | change */
20 | });
21 |
22 | ### Getting info
23 |
24 | fs.exists('file.txt', function(exists /*bool*/) { ... });
25 |
26 | fs.stat('file.txt', function(stats) {
27 | stats.isFile();
28 | stats.isDirectory();
29 | stats.isSymbolicLink();
30 | });
31 |
32 | ### File operations
33 |
34 | fs.rename('old.txt', 'new.txt', function(){});
35 | fs.chown('file.txt', uid, gid, function(){});
36 | fs.symlink('src', 'dest', function(){});
37 | fs.unlink('path', function(){});
38 | fs.rmdir('path', function(){});
39 |
40 | fs.readdir('path', function(err, files) { .. }); /* `files` = array of names */
41 |
42 | ### Path
43 |
44 | fs.realpath('/etc/passwd', function(err, path) { /* "/private/etc/passwd" */ });
45 |
46 | ### Sync
47 |
48 | data = fs.readFileSync('input.txt');
49 | fs.writeFileSync('output.txt', data);
50 | fs.appendFileSync('output.txt', data);
51 | fs.existsSync('file.txt');
52 |
53 | ### References
54 |
55 | - https://nodejs.org/api/fs.html
56 |
--------------------------------------------------------------------------------
/projectionist.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Projectionist
3 | category: Vim
4 | ---
5 |
6 | ### Basic usage
7 |
8 | ```json
9 | /* .projectionist.vim */
10 | {
11 | "app/assets/react/components/*.jsx": {
12 | "type": "component",
13 | "template": [
14 | "import React from 'react'",
15 | "export default {} = React.createClass({ ... })"
16 | ]
17 | }
18 | ```
19 |
20 | ### Available options
21 |
22 | ```js
23 | {
24 | "lib/*.rb": {
25 | "type": "lib", /* enables :Elib */
26 | "alternate": "test/{}_spec.rb", /* for :A */
27 | "template": [ ... ],
28 |
29 | "path": "include", /* for `gf` i think */
30 |
31 | "console": "node", /* for :Console */
32 | "dispatch": "node", /* for :Dispatch (dispatch.vim) */
33 | "start": "rails server", /* for :Start (dispatch.vim) */
34 | "make": "node", /* for makeprg */
35 | }
36 | }
37 | ```
38 |
39 | ### Commands
40 |
41 | | Command | Description |
42 | |---------|-------------|
43 | | `:A` | Edit alternate |
44 | | `:A {file}` | Edit file |
45 | |---------|-------------|
46 | | `:AS` | Edit in split |
47 | | `:AV` | Edit in vsplit |
48 | | `:AT` | Edit in tab |
49 | |---------|-------------|
50 | | `:AD` | Replace with template |
51 | |---------|-------------|
52 | | `:Cd` | cd to root |
53 | | `:Cd {path}` | cd to path in root |
54 | | `:Lcd` | cd to root using :lcd |
55 | |---------|-------------|
56 | | `:ProjectDo {cmd}` | run command in root |
57 |
58 | ### Reference
59 |
60 | See [vim-projectionist](https://github.com/tpope/vim-projectionist).
61 |
--------------------------------------------------------------------------------
/rails-tricks.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Rails tricks
3 | category: Rails
4 | tags: [Archived]
5 | archived: This sheet may describe practices that might be outdated.
6 | ---
7 |
8 | ### Sass source maps
9 |
10 | in config/environments/development.rb:
11 |
12 | # Source maps for Sass
13 | config.sass.debug_info = true
14 | config.sass.line_comments = false
15 |
16 | # Don't break apart
17 | config.assets.debug = false
18 |
19 | ### Partial locals
20 |
21 | <%= render 'article', full: true %>
22 | <%= render 'article' %>
23 |
24 | <% if local_assigns[:full] %>
25 | ...
26 | <% end %>
27 |
28 | ### HTML in i18n
29 |
30 | en:
31 | read_more_html: "read more..."
32 |
33 | ### Exception handling
34 |
35 | # config/application.rb
36 | config.exceptions_app = self.routes
37 |
38 | get '/404', to: 'errors#not_found'
39 | get '/500', to: 'errors#server_error'
40 |
41 | class ErrorsController
42 | def not_found
43 | render status: :not_found
44 | end
45 | end
46 |
47 | ### Rails updating
48 |
49 | rake rails:update
50 |
51 | ### Distinct pluck
52 |
53 | Article.distinct.pluck('author')
54 |
55 | ### Relation#merge
56 |
57 | scope :with_drafts, -> {
58 | uniq.joins(:articles).merge(Article.draft)
59 | }
60 |
61 | ### Order
62 |
63 | scope :recent, -> { order created_at: :desc }
64 |
65 | ### Group by month
66 |
67 | .group("to_char(created_at, 'YYYY-MM')")
68 | .group("to_char(created_at, 'YYYY-MM')").count
69 |
--------------------------------------------------------------------------------
/src/lib/seo/jsonJd.test.ts:
--------------------------------------------------------------------------------
1 | import { getJSONLDsForPage } from './jsonLd'
2 |
3 | it('works', () => {
4 | const page = {
5 | slug: 'react',
6 | frontmatter: {
7 | title: 'React',
8 | description: 'A React cheatsheet',
9 | category: 'JavaScript'
10 | }
11 | }
12 |
13 | const output = getJSONLDsForPage(page)
14 | expect(output).toMatchInlineSnapshot(`
15 | [
16 | {
17 | "@context": "http://schema.org",
18 | "@type": "NewsArticle",
19 | "description": "A React cheatsheet · One-page guide to React",
20 | "headline": "React cheatsheet",
21 | "image": [
22 | "https://assets.devhints.io/previews/react.jpg",
23 | ],
24 | "mainEntityOfPage": {
25 | "@id": "https://google.com/article",
26 | "@type": "WebPage",
27 | },
28 | },
29 | {
30 | "@context": "http://schema.org",
31 | "@type": "BreadcrumbList",
32 | "itemListElement": [
33 | {
34 | "@type": "ListItem",
35 | "item": {
36 | "@id": "https://devhints.io/#javascript",
37 | "name": "JavaScript",
38 | },
39 | "position": 1,
40 | },
41 | {
42 | "@type": "ListItem",
43 | "item": {
44 | "@id": "https://devhints.io/react",
45 | "name": "React cheatsheet",
46 | },
47 | "position": 2,
48 | },
49 | ],
50 | },
51 | ]
52 | `)
53 | })
54 |
--------------------------------------------------------------------------------
/kramdown.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Kramdown
3 | category: Markup
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | Kramdown is a Markdown parser in Ruby.
10 |
11 | -
12 |
13 | ### Configuration
14 |
15 | * `parse_block_html` - process kramdown syntax inside blocks
16 | * `parse_span_html` - process kramdown syntax inside inlines
17 | * `html_to_native` - convert html elements to native elements
18 |
19 | {::options parse_block_html="true" /}
20 |
21 | For the GFM parser:
22 |
23 | * `hard_wrap`
24 |
25 | http://kramdown.gettalong.org/parser/gfm.html
26 |
27 | ### For jekyll (gh-pages)
28 |
29 | # _config.yml
30 | markdown: kramdown
31 | kramdown:
32 | input: GFM
33 |
34 | ### Footnotes (Kramdown)
35 |
36 | This is some text.[^1]. Other text.[^footnote].
37 |
38 | [^1]: Some *crazy* footnote definition.
39 |
40 | ### Abbreviations (Kramdown)
41 |
42 | This is some text not written in HTML but in another language!
43 |
44 | *[another language]: It's called Markdown
45 | *[HTML]: HyperTextMarkupLanguage
46 |
47 | ### Classes and IDs (Kramdown)
48 |
49 | A simple paragraph with an ID attribute.
50 | {: #para-one}
51 |
52 | > A blockquote with a title
53 | {:title="The blockquote title"}
54 | {: #myid}
55 |
56 | * {:.cls} This item has the class "cls"
57 |
58 | {:.ruby}
59 | Some code here
60 |
61 | ### References
62 |
63 | * http://kramdown.gettalong.org/syntax.html
64 | * http://kramdown.gettalong.org/parser/kramdown.html
65 |
--------------------------------------------------------------------------------
/src/lib/fuseSearch/fuseSearch.ts:
--------------------------------------------------------------------------------
1 | import Fuse from 'fuse.js'
2 | import type { SheetPage } from '~/lib/page'
3 |
4 | /**
5 | * This is what gets served in searchindex.json
6 | */
7 |
8 | export type ExternalSearchData = {
9 | index: ReturnType
10 | rows: Array<{ title: string; slug: string }>
11 | }
12 |
13 | export type Row = { title: string; slug: string }
14 |
15 | export type FuseIndex = Fuse.FuseIndex
16 |
17 | /** A subset of `SheetPage` needed for search indexing */
18 | type PartialSheetPage = {
19 | slug: SheetPage['slug']
20 | frontmatter: Pick
21 | }
22 |
23 | /**
24 | * Get `pages` and turn them into a fuse index json.
25 | */
26 |
27 | export function buildFuseIndex(pages: Record) {
28 | const rows = Object.values(pages).map((page): Row => {
29 | return { title: (page.frontmatter.title ?? '') as string, slug: page.slug }
30 | })
31 | const myIndex: FuseIndex = Fuse.createIndex(['title', 'slug'], rows)
32 | const indexJSON = myIndex.toJSON()
33 |
34 | const result = { index: indexJSON, rows }
35 | return result
36 | }
37 |
38 | export async function fetchFuse() {
39 | const res = await fetch('/searchindex.json')
40 | if (res.status > 400) throw new Error('Failed to fetch searchindex.json')
41 | return res.json()
42 | }
43 |
44 | export function parseFuse(data: ExternalSearchData) {
45 | const index = Fuse.parseIndex(data.index)
46 | const fuse = new Fuse(data.rows, {}, index)
47 | return fuse
48 | }
49 |
--------------------------------------------------------------------------------
/src/sass/2017/components/related-post-item.scss:
--------------------------------------------------------------------------------
1 | .related-post-item {
2 | & {
3 | display: flex;
4 | text-align: left;
5 | line-height: 1.4;
6 | }
7 |
8 | // Layout
9 | & > a {
10 | flex: 1 1 100%;
11 | display: block;
12 | border-radius: 2px;
13 | box-shadow: $shadow2;
14 | padding: 16px;
15 | text-decoration: none;
16 | }
17 |
18 | // Color
19 | & > a,
20 | & > a:visited {
21 | background: white;
22 | color: $base-mute;
23 |
24 | & > strong {
25 | color: $base-a;
26 | }
27 |
28 | &:hover,
29 | &:focus {
30 | color: $base-a;
31 | }
32 |
33 | &:hover > strong,
34 | &:focus > strong {
35 | color: darken($base-a, 16%);
36 | }
37 | }
38 |
39 | &:first-of-type > a,
40 | &:first-of-type > a:visited {
41 | background: $base-a;
42 | color: rgba(white, 0.5);
43 |
44 | & > strong {
45 | color: white;
46 | }
47 |
48 | &:hover,
49 | &:focus {
50 | color: white;
51 | }
52 |
53 | &:hover > strong,
54 | &:focus > strong {
55 | color: white;
56 | }
57 |
58 | &:hover,
59 | &:focus {
60 | background: darken($base-a, 8%);
61 | }
62 | }
63 |
64 | // Two lines when bigger
65 | @media (min-width: 481px) {
66 | & > a > strong,
67 | & > a > span {
68 | display: block;
69 | }
70 | }
71 |
72 | & > a > strong {
73 | @include font-size(1);
74 | font-weight: normal;
75 | }
76 |
77 | & > a > span {
78 | @include font-size(-1);
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/tailwind.config.mjs:
--------------------------------------------------------------------------------
1 | import resolveConfig from 'tailwindcss/resolveConfig'
2 |
3 | const defaults = resolveConfig({})
4 |
5 | /** @type {import('tailwindcss').Config} */
6 | export default {
7 | content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
8 | theme: {
9 | extend: {
10 | spacing: {
11 | // max-widths
12 | content: '1232px',
13 | slim: '740px'
14 | },
15 | colors: {
16 | mildindigo: {
17 | 50: '#F2F1F8',
18 | 100: '#E8E7F3',
19 | 200: '#D0CFE8',
20 | 300: '#B5B4DA',
21 | 400: '#9E9CCF',
22 | 500: '#8784C3',
23 | 600: '#6F6BB7',
24 | 700: '#4C4893',
25 | 800: '#312F60',
26 | 900: '#191730',
27 | 950: '#0C0C18'
28 | }
29 | },
30 |
31 | fontFamily: {
32 | manrope: ['Manrope', ...defaults.theme.fontFamily.sans]
33 | },
34 |
35 | boxShadow: {
36 | 'lg-cool': [
37 | '0 1px 1px rgb(0 0 80 / 0.05)',
38 | '0 1.5px 3px -1px rgb(0 0 80 / 0.15)',
39 | '0 4px 6px -1px rgb(0 0 80 / 0.07)',
40 | '0 8px 12px -1px rgb(0 0 80 / 0.04)'
41 | ].join(', '),
42 | 'md-cool': [
43 | '0 0 0 1px rgb(0 0 80 / 0.1)',
44 | '0 1px 1px rgb(0 0 80 / 0.1)',
45 | '0 1.5px 3px -2px rgb(0 0 80 / 0.3)',
46 | '0 4px 6px rgb(0 0 80 / 0.04)',
47 | '0 8px 12px -1px rgb(0 0 80 / 0.03)'
48 | ].join(', ')
49 | }
50 | }
51 | },
52 | plugins: []
53 | }
54 |
--------------------------------------------------------------------------------
/umdjs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Universal JS module loader
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Reference
7 |
8 | *
9 |
10 | ### [With dependency](https://github.com/umdjs/umd/blob/master/amdWebGlobal.js)
11 |
12 | ~~~ js
13 | ;(function (root, factory) {
14 |
15 | if (typeof define === 'function' && define.amd) {
16 | define(['jquery'], factory);
17 | } else if (typeof exports === 'object') {
18 | module.exports = factory(require('jquery'));
19 | } else {
20 | root.YourModule = factory(root.jQuery);
21 | }
22 |
23 | }(this, function (jquery) {
24 | return {};
25 | }));
26 | ~~~
27 |
28 | ### No dependencies
29 |
30 | ~~~ js
31 | ;(function (root, factory) {
32 |
33 | if (typeof define === 'function' && define.amd) {
34 | define(factory);
35 | } else if (typeof exports === 'object') {
36 | module.exports = factory();
37 | } else {
38 | root.YourModule = factory();
39 | }
40 |
41 | }(this, function () {
42 | return {};
43 | }));
44 | ~~~
45 |
46 | ### [Supports circular references](https://github.com/umdjs/umd/blob/master/commonjsStrict.js)
47 |
48 | ~~~ js
49 | (function (root, factory) {
50 |
51 | if (typeof define === 'function' && define.amd) {
52 | define(['exports', 'jquery'], factory);
53 | } else if (typeof exports === 'object') {
54 | factory(exports, require('jquery'));
55 | } else {
56 | factory((root.YourModule = {}), root.jQuery);
57 | }
58 |
59 | }(this, function (exports, jQuery) {
60 | exports.action = function () {};
61 | }));
62 | ~~~
63 |
--------------------------------------------------------------------------------
/src/sass/2017/components/announcements-item.scss:
--------------------------------------------------------------------------------
1 | .announcements-item {
2 | & {
3 | position: relative;
4 | padding: 16px;
5 | box-shadow: $shadow6;
6 | border-radius: 1px;
7 | background: white;
8 | padding-right: 48px;
9 | animation: announcements-item-flyin 500ms ease-out;
10 | transition:
11 | opacity 500ms linear,
12 | transform 500ms ease-out;
13 | }
14 |
15 | &.-hide {
16 | display: none;
17 | }
18 |
19 | & > .title {
20 | @include font-size(1);
21 | font-weight: normal;
22 | color: $base-a;
23 | margin: 0;
24 | padding: 0;
25 | }
26 |
27 | & > .body > p {
28 | margin: 0;
29 | padding: 0;
30 |
31 | & + p {
32 | margin-top: 1em;
33 | }
34 | }
35 |
36 | & > .close {
37 | position: absolute;
38 | right: 0;
39 | top: 0;
40 | width: 40px;
41 | height: 40px;
42 | line-height: 40px;
43 | text-align: center;
44 | border: 0;
45 | margin: 0;
46 | padding: 0;
47 | cursor: pointer;
48 | background: transparent;
49 |
50 | &:hover,
51 | &:focus {
52 | color: $base-a;
53 | }
54 | }
55 |
56 | & > .close::before {
57 | // https://stackoverflow.com/a/30421654
58 | content: unquote('"') + str-insert('00D7', '\\', 1) + unquote('"');
59 | font-size: 14px;
60 | }
61 | }
62 |
63 | @keyframes announcements-item-flyin {
64 | 0% {
65 | transform: translate3d(0, 32px, 0);
66 | opacity: 0;
67 | }
68 |
69 | 100% {
70 | transform: translate3d(0, 0, 0);
71 | opacity: 1;
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/tar.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: tar
3 | category: CLI
4 | updated: 2022-08-11
5 | intro: Concatenate, Deflate, Inflate files
6 | ---
7 | ## Reference
8 | {:.-two-column}
9 |
10 | ### Deflate / Inflate / Concatenate
11 | ```shell
12 | # Deflate / Compress
13 | tar -czf archive.tar.gz /path/files
14 | ```
15 |
16 | ```shell
17 | # Inflate / Uncompress
18 | tar -xzf archive.tar.gz
19 | ```
20 |
21 | ```shell
22 | # Concatenate files into a single tar
23 | tar -cf archive.tar /path/files
24 | ```
25 |
26 | ```shell
27 | # Extract file to a defined directory
28 | tar -xzf archive.tar.gz -C /target/directory
29 | ```
30 |
31 | ```shell
32 | # Append a file to an existing archive
33 | tar -zu archive.tar.gz -C /target/file
34 | ```
35 |
36 | ```shell
37 | # List files in archive
38 | # Add -v for additional details
39 | tar -tzf archive.tar.gz
40 | ```
41 |
42 | ### Common options
43 |
44 | | Option | Description |
45 | |--------|-------------------------------------------------------------------------|
46 | | `z` | compress with gzip |
47 | | `c` | create an archive |
48 | | `u` | append files which are newer than the corresponding copy in the archive |
49 | | `f` | filename of the archive |
50 | | `v` | verbose, display what is inflated or deflated |
51 | | `a` | unlike of `z`, determine compression based on file extension |
52 |
--------------------------------------------------------------------------------
/rtorrent.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: rTorrent
3 | category: CLI
4 | intro: |
5 | [rTorrent](https://rakshasa.github.io/rtorrent/) is a command-line torrent application. Here are some shortcut keys.
6 | ---
7 |
8 | ## Shortcuts
9 | {: .-three-column}
10 |
11 | ### Global
12 |
13 | | `^q` | Quit |
14 | {: .-shortcuts}
15 |
16 | ### Main view
17 |
18 | | Shortcut | Description |
19 | | --- | --- |
20 | | `bksp` | Add torrent |
21 | | --- | --- |
22 | | `->` | View download |
23 | | --- | --- |
24 | | `1` _-_ `7` | Change view |
25 | | --- | --- |
26 | | `^S` | Start download |
27 | | `^D` | Stop download (or remove stopped) |
28 | | `^K` | Close a torrent |
29 | | --- | --- |
30 | | `+` _/_ `-` | Change priority |
31 | {: .-shortcuts}
32 |
33 | ### Throttling
34 |
35 | #### Upload
36 |
37 | | `a` _/_ `s` _/_ `d` | Increase upload throttle by 1/5/50 KB |
38 | | `z` _/_ `x` _/_ `c` | Decrease upload throttle by 1/5/50 KB |
39 | {: .-shortcuts}
40 |
41 | #### Download
42 |
43 | | `A` _/_ `S` _/_ `D` | Increase download throttle by 1/5/50 KB |
44 | | `Z` _/_ `X` _/_ `C` | Decrease download throttle by 1/5/50 KB |
45 | {: .-shortcuts}
46 |
47 | ### Download view
48 |
49 | | `1` _/_ `2` | Adjust max uploads |
50 | | `3` _/_ `4` | Adjust min peers |
51 | | `5` _/_ `6` | Adjust max peers |
52 | {: .-shortcuts}
53 |
54 | ### File list view
55 |
56 | | `space` | Change priority |
57 | {: .-shortcuts}
58 |
59 | ## Also see
60 |
61 | - [rTorrent website](https://rakshasa.github.io/rtorrent/) _(rakshasa.github.io)_
62 | - [rTorrent wiki](https://github.com/rakshasa/rtorrent/wiki) _(github.com)_
63 |
--------------------------------------------------------------------------------
/yargs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Yargs
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### Basic usage
7 |
8 | ```js
9 | var argv = require('yargs').argv;
10 |
11 | argv._ // [ ... ]
12 | argv.$0 // "node bin/mybin"
13 | argv.verbose // --verbose
14 | ```
15 |
16 | ### Help and version
17 |
18 | ```js
19 | var argv = require('yargs')
20 |
21 | // version
22 | .alias('v', 'version')
23 | .version(function() { return require('../package').version; })
24 | .describe('v', 'show version information')
25 |
26 | // help text
27 | .alias('h', 'help')
28 | .help('help')
29 | .usage('Usage: $0 -x [num]')
30 | .showHelpOnFail(false, "Specify --help for available options")
31 | ```
32 |
33 | ### Options
34 |
35 | ```js
36 | .option('f', {
37 | alias : 'file',
38 | describe: 'x marks the spot',
39 | type: 'string', /* array | boolean | string */
40 | nargs: 1,
41 | demand: true,
42 | demand: 'file is required',
43 | default: '/etc/passwd'
44 | // also: count:true, requiresArg:true
45 | })
46 |
47 | .options({
48 | f: { ... }
49 | })
50 | ```
51 |
52 | ### Examples and more help stuff
53 |
54 | ```js
55 | // more help
56 | .example('...')
57 | .epilog('copyright 2015')
58 | .command('start', 'start a server')
59 | ```
60 |
61 | ### Stacking
62 |
63 | ```js
64 | .count('verbose')
65 |
66 | argv.verbose // -vvv => 3
67 | ```
68 |
69 | ### Reject non explicits
70 |
71 | ```js
72 | .strict()
73 | ```
74 |
75 | ### Methods
76 |
77 | ```
78 | yargs.showHelp()
79 | yargs.help() //=>string
80 | ```
81 |
--------------------------------------------------------------------------------
/sequelize.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Sequelize
3 | category: JavaScript libraries
4 | ---
5 |
6 | ### About
7 | {: .-intro}
8 |
9 | Sequelize is an ORM for JavaScript.
10 |
11 | -
12 |
13 | ### API
14 |
15 | sequelize.sync().done -> ...
16 |
17 | ### Models
18 |
19 | Project = sequelize.define('Project', {
20 | title: Sequelize.STRING,
21 | description: Sequelize.TEXT,
22 | myDate: { type: Sequelize.DATE, defaultValue: Sequelize.NOW },
23 | title: { type: Sequelize.STRING, allowNull: false },
24 | id: { type: Sequelize.INTEGER, autoIncrement: true, primaryKey: true },
25 | }, {
26 | classMethods: { ... },
27 | instanceMethods: { ... }
28 | });
29 |
30 | Project.hasMany(Task)
31 |
32 | ### Finders
33 |
34 | Project.find(123).success (project) ->
35 |
36 | Project.find({ where: {title: 'Hello'} })
37 | Project.find({ where: {id: [1,3,4]} })
38 | Project.find({ where: ["id > ?", 25] })
39 |
40 | Project.find(
41 | where: {title: 'a'}
42 | attributes: ['id', ['name', 'title']]
43 | )
44 |
45 | .findOrCreate(...)
46 |
47 | .findAll
48 | .findAll({ where: ... })
49 | .findAll({ order: 'title DESC' })
50 | .findAll({ limit: 10 })
51 | .findAll({ offset: 10, limit: 2 })
52 |
53 | .count()
54 |
55 |
56 | ### Build
57 |
58 | item = Project.build({ ... })
59 |
60 | item.title = '...'
61 |
62 | item.save().success (item) ->
63 |
64 | item.updateAttributes({ title: '...' })
65 |
66 | item.destroy().success ->
67 |
68 | item.values
69 |
70 |
--------------------------------------------------------------------------------
/src/scripts/v2017/behaviors_2/anchors.js:
--------------------------------------------------------------------------------
1 | const DEFAULTS = {
2 | // select elements to put anchor on
3 | rule: 'h2[id]',
4 | // class name for anchor
5 | className: 'local-anchor anchor',
6 | // text of anchor
7 | text: '#',
8 | // append before or after innerText?
9 | shouldAppend: true
10 | }
11 |
12 | /*
13 | * Behavior: Add local anchors
14 | */
15 |
16 | export function setupAnchors() {
17 | document.querySelectorAll('[data-js-anchors]').forEach((parent) => {
18 | const data = JSON.parse(parent.getAttribute('data-js-anchors') || '{}')
19 | const rules = Array.isArray(data)
20 | ? data.length
21 | ? data
22 | : [DEFAULTS]
23 | : [Object.assign({}, DEFAULTS, data)]
24 |
25 | for (const { rule, className, text, shouldAppend } of rules) {
26 | for (const el of parent.querySelectorAll(rule)) {
27 | if (!el.hasAttribute('id')) {
28 | continue
29 | }
30 |
31 | const id = el.getAttribute('id')
32 | const anchor = document.createElement('a')
33 | anchor.setAttribute('href', `#${id}`)
34 | anchor.setAttribute('class', className)
35 | anchor.setAttribute('aria-hidden', 'true')
36 | anchor.innerText = String(text || DEFAULTS.text)
37 |
38 | if (shouldAppend) {
39 | el.appendChild(anchor)
40 | } else {
41 | prepend(el, anchor)
42 | }
43 | }
44 | }
45 | })
46 | }
47 |
48 | function prepend(el, child) {
49 | if (el.firstChild) {
50 | el.insertBefore(child, el.firstChild)
51 | } else {
52 | el.appendChild(child)
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/moment.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Moment.js
3 | category: JavaScript libraries
4 | updated: 2018-09-15
5 | tags: [Featurable]
6 | ---
7 |
8 | ### Parsing
9 |
10 | ```js
11 | m = moment('2013-03-01', 'YYYY-MM-DD')
12 | ```
13 |
14 | This parses the given date using the given format. Returns a moment object.
15 |
16 | ### Formatting
17 |
18 | ```js
19 | m.format() // "2013-03-01T00:00:00+01:00"
20 | m.format('dddd') // "Friday"
21 | m.format('MMM Do YY') // "Mar 1st 13"
22 | m.fromNow() // "7 years ago"
23 | m.calendar() // "03/01/2013"
24 | ```
25 |
26 | ### Add
27 |
28 | ```js
29 | m.add(1, 'day')
30 | m.subtract(2, 'days')
31 | ```
32 |
33 | ```js
34 | m.startOf('day')
35 | m.endOf('day')
36 | m.startOf('hour')
37 | ```
38 |
39 | ### Internationalization
40 |
41 | ```js
42 | .format('L') // 06/09/2014
43 | .format('l') // 6/9/2014
44 | .format('LL') // June 9 2014
45 | .format('ll') // Jun 9 2014
46 | .format('LLL') // June 9 2014 9:32 PM
47 | .format('lll') // Jun 9 2014 9:32 PM
48 | .format('LLLL') // Monday, June 9 2014 9:32 PM
49 | .format('llll') // Mon, Jun 9 2014 9:32 PM
50 | ```
51 |
52 | See [datetime](./datetime) for more.
53 |
54 | {% include common/moment_format.md title="Formatting" %}
55 |
56 | ## References
57 |
58 | ### Alternatives
59 |
60 | * [You don't need Moment.js](https://github.com/you-dont-need/You-Dont-Need-Momentjs) _(github.com)_
61 |
62 | ### Also see
63 |
64 | * [Datetime cheatsheet](./datetime) _(devhints.io)_
65 | * [Moment website](http://momentjs.com/) _(momentjs.com)_
66 | * [Moment docs](http://momentjs.com/docs/) _(momentjs.com)_
67 |
--------------------------------------------------------------------------------
/src/components/SocialList.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import { getUrlFromPage } from '~/lib/links'
3 | import type { SheetPage } from '~/lib/page'
4 |
5 | export type Props = {
6 | class?: string
7 | page?: SheetPage
8 | }
9 | const props = Astro.props as Props
10 | const page = props.page
11 | const url = getUrlFromPage(page, Astro.site)
12 |
13 | const t = {
14 | facebookShare: 'Share on Facebook',
15 | twitterShare: 'Share on Twitter',
16 | sheetDescription: 'The ultimate cheatsheet for {title}',
17 | defaultDescription: 'Ridiculous collection of web development cheatsheets'
18 | }
19 |
20 | const title = page?.frontmatter?.title
21 |
22 | const description = title
23 | ? t.sheetDescription.replace('{title}', title)
24 | : t.defaultDescription
25 |
26 | const tweet = `${description} ${url}`
27 |
28 | // prettier-ignore
29 | const facebookURL = `https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(url)}`
30 | // prettier-ignore
31 | const twitterURL = `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweet)}`
32 | ---
33 |
34 |
35 | -
36 |
42 |
43 | {' '}
44 |
52 |
53 |
--------------------------------------------------------------------------------
/awscli.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: AWS CLI
3 | category: Devops
4 | ---
5 |
6 | ### EC2
7 |
8 | ```
9 | aws ec2 describe-instances
10 | aws ec2 start-instances --instance-ids i-12345678c
11 | aws ec2 terminate-instances --instance-ids i-12345678c
12 | ```
13 |
14 | ### S3
15 |
16 | ```
17 | aws s3 ls s3://mybucket
18 | aws s3 rm s3://mybucket/folder --recursive
19 | aws s3 cp myfolder s3://mybucket/folder --recursive
20 | aws s3 sync myfolder s3://mybucket/folder --exclude *.tmp
21 | ```
22 |
23 | ### ECS
24 |
25 | ```
26 | aws ecs create-cluster
27 | --cluster-name=NAME
28 | --generate-cli-skeleton
29 |
30 | aws ecs create-service
31 | ```
32 |
33 | ### Homebrew
34 |
35 | ```
36 | brew install awscli
37 | aws configure
38 | ```
39 |
40 | ### Configuration profiles
41 |
42 | ```
43 | aws configure --profile project1
44 | aws configure --profile project2
45 | ```
46 |
47 | ## Elastic Beanstalk
48 |
49 | ### Configuration
50 |
51 | * .elasticbeanstalk/config.yml - application config
52 | * .elasticbeanstalk/dev-env.env.yml - environment config
53 |
54 | ```
55 | eb config
56 | ```
57 |
58 | See:
59 |
60 | ## ebextensions
61 |
62 | *
63 | *
64 |
65 | ## Also see
66 |
67 | * [AWS CLI](https://aws.amazon.com/cli/)
68 | * [Documentation](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-welcome.html)
69 | * [All commands](https://docs.aws.amazon.com/cli/latest/reference/#available-services)
70 |
--------------------------------------------------------------------------------