Skip to content

Instantly share code, notes, and snippets.

View aleph-naught2tog's full-sized avatar

Max Cerrina aleph-naught2tog

View GitHub Profile
@aleph-naught2tog
aleph-naught2tog / scss_cloud9.md
Created February 3, 2018 13:35
SCSS Cloud9 Installation and Primer

Basic SASS/SCSS Guide

http://sass-lang.com/guide

Notes

Examples of the code itself are going to be in SCSS. SCSS uses its own syntax as well as CSS's syntax. That is: all CSS, without you doing anything to it, is valid SCSS. SASS uses its own syntax.

Installation

These are the instructions for installing SASS/SCSS to your server, so you can use SASS/SCSS to compile down to CSS.

// context: https://i.redd.it/3co31eqj37j01.jpg
import java.util.*;
public class SelfExplanatory implements Comparable {
private String selfExplanatory;
private int se1fExplanatory;
private int selfexp1anatory;
private Map<SelfExplanatory, SelfExplanatory> selfExplanatories;
@aleph-naught2tog
aleph-naught2tog / readable.js
Last active April 29, 2018 18:41
Java API Sorting Bookmarklet
/*
For sorting the method tables by return type in the Java API.
To use: make a bookmarklet whose URL is exactly the following:
javascript:(function(){const%20TABLE_CLASS=".memberSummary";const%20ROWS_OTHER_THAN_FIRST_SELECTOR="tr:not(:first-child)";const%20methodTable=document.querySelector(TABLE_CLASS);const%20tbody=methodTable.querySelector("tbody");const%20allRows=tbody.querySelectorAll(ROWS_OTHER_THAN_FIRST_SELECTOR);const%20sortAlphabetically=(firstString,secondString)=>{if(firstString===secondString){return%200;}if(firstString<secondString){return-1;}if(firstString>secondString){return%201;}};const%20sortByInnerText=(firstHtmlElement,secondHtmlElement)=>{const%20firstText=firstHtmlElement.innerText;const%20secondText=secondHtmlElement.innerText;return%20sortAlphabetically(firstText,secondText);};const%20sortRowByFirstColumn=(firstRow,secondRow)=>{return%20sortByInnerText(firstRow.querySelector("td"),secondRow.querySelector("td"));};const%20sortByJdocRowId=(firstJavadocRow,secondJavadocRow)=>{c
/*
setup notes: needs the compiler option:
`"experimentalDecorators": true,` in your tsconfig
*/
function StaticImplements<T>() {
return (_constructor: T) => {};
}
interface Type<T> {
@aleph-naught2tog
aleph-naught2tog / regex_whitespace.md
Last active August 25, 2018 22:25
Regex whitespace example

readable regex

Most languages allow a flag called the ignore-whitespace or free-spacing flag. Most of the major languages support it for their regular expression implementations -- with Javascript being the outlier here, as usual. Ruby, PHP, Elixir, etc., all support it. Java too.

What it does is makes it so that when the engine sees whitespace, it ignores it entirely.

So say we wanted to parse some HTML with regular expressions, like this:

@aleph-naught2tog
aleph-naught2tog / bloop.md
Last active September 1, 2018 22:35
More regex readability comparisons

These two regular expressions are equivalent. Both use PHP's flavor of PCRE. (The first one might actually work for other languages PCRE variants as well, I'm not sure.) Neither will work for Javascript--it's pretty impossible to tell, but the first one does still have the conditionals, etc., as the second one. Just, you know, illegibly.

You'll have to horizontal-scroll a decent amount on that first one, too. (And also hope you never, ever, ever need to make changes.)

(?:((?:const)|(?:var))|(?:function))\s+(\w+)(?(1)(?:\s*=\s*(?:(?:function)(?:\s*\w+)?)?)|(?=\s*\())\(([^\)]*)\)(\h*=>\s*)?((?s)\s*\{\s*(?-s))?(?(5)([\s\S]*?)return\s)((?:\V++$\v)?(?:^\h+\V+$\v)*)(?(5)^\};?)

and:

@aleph-naught2tog
aleph-naught2tog / hello_asm.s
Last active December 30, 2018 05:32
Assembler
# hello_asm.s
# as hello_asm.s -o hello_asm.o
# ld hello_asm.o -e _main -o hello_asm -macosx_version_min 10.6 -lSystem
.section __DATA,__data
str:
.asciz "Hello world!\n"
.section __TEXT,__text
.globl _main
@aleph-naught2tog
aleph-naught2tog / postgresql.md
Created January 1, 2019 18:11
"Role 'postgres' does not exist"

Postgres

This was initially specifically in relation to errors when setting up Phoenix/Mix in relation to Postgres.

  1. From the command line: createdb. This creates the default database for the user you are currently logged in as.
@aleph-naught2tog
aleph-naught2tog / phoenix_notes.md
Created January 1, 2019 18:13
General phoenix notes

(NB: this was done initially for Phoenix 1.3 and I haven't updated it yet.)

phoenix

requirements

  • erlang
  • elixir
  • mix
  • phoenix

???

@aleph-naught2tog
aleph-naught2tog / emotion_ts.ts
Last active January 5, 2019 00:31
Explanation below in comment
import { Omit, Overwrapped } from '@emotion/styled-base/types/helper';
import { Interpolation } from '@emotion/serialize';
import { WithTheme, StyledComponent } from '@emotion/styled-base';
// -------
// This is just to shush the compiler
type Theme = {};
type InnerProps = {};