Skip to content

Instantly share code, notes, and snippets.

View Asjas's full-sized avatar
🔥

A-J Roos Asjas

🔥
  • South Africa
  • 17:50 (UTC +02:00)
  • X @_asjas
View GitHub Profile
@Asjas
Asjas / luhnAlgorithm.ts
Created July 8, 2022 18:01
Luhn Algorithm
// https://github.com/muhammadghazali/mod10
function LuhnAlgorithm(RSA_ID: string) {
let isValid = false;
let checkDigit;
let sumOfAllNumbers = 0;
let reversedIdentifier = [];
const identifierString = RSA_ID;
checkDigit = identifierString.charAt(identifierString.length - 1);
@Asjas
Asjas / app.js
Created May 21, 2022 10:07
React "as" Prop Example
const Headline = ({ as = 'h1', children }) => {
const As = as;
return <As>{children}</As>;
};
const App = () => {
return (
<>
<Headline>Hello React</Headline>
<Headline as="h2">Hello React</Headline>
@Asjas
Asjas / reset.css
Last active October 17, 2023 23:13
My CSS Reset
/* Box sizing rules */
html {
box-sizing: border-box;
}
/* Set core root defaults */
html:focus-within {
scroll-behavior: smooth;
}
@Asjas
Asjas / scss.txt
Created May 19, 2021 07:12
Pretty neat SCSS folder structure
// https://matthiasott.com/notes/how-i-structure-my-css
/scss/
├── 1-settings
│ └── _global.scss
├── 2-design-tokens
│ ├── _colors.scss
│ ├── _fonts.scss
│ ├── _media-queries.scss
│ ├── _spacing.scss
@Asjas
Asjas / reset.css
Created May 19, 2021 07:09
Modern CSS Reset - Andy Bell
// https://piccalil.li/blog/a-modern-css-reset
/* Box sizing rules */
*,
*::before,
*::after {
box-sizing: border-box;
}
/* Remove default margin */
@Asjas
Asjas / index.js
Last active March 22, 2021 15:41
Node Backpressure Aware Copy
function backpressureAwareCopy(srcStream, destStream) {
srcStream.on('data', (chunk) => {
const canContinue = destStream.write(chunk);
if (!canContinue) {
// if we are overflowing the destination, we stop reading
srcStream.pause();
// once all the buffered data is flushed, we resume reading from source
destStream.once('drain', () => srcStream.resume());
}
})
@Asjas
Asjas / system-queries.sql
Created February 28, 2021 19:09
PostgreSQL System Table Queries
// This query returns a list of tables, in alphabetical order, with a count of the columns.
SELECT table_name
,COUNT(column_name)
FROM information_schema.columns
WHERE table_schema = 'myschema' -- put your schema here
GROUP BY table_name
ORDER BY table_name;
// This query returns a list of tables, in alphabetical order, with a count of the rows.
@Asjas
Asjas / index.js
Created February 16, 2021 21:04
Node.js ES modules __dirname and __filename
import { fileURLToPath } from 'url';
import { dirname } from 'path';
console.log(`import.meta.url: ${import.meta.url}`);
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
console.log(`dirname: ${__dirname}`);
console.log(`filename: ${__filename}`);
@Asjas
Asjas / Dockerfile
Last active September 20, 2020 15:36
Example Node.js Production Dockerfile
FROM node:10.16.2-stretch
EXPOSE 3000
ENV NODE_ENV production
# Create work environment and set up app
RUN mkdir /app && chown -R node:node /app
WORKDIR /app
USER node
// Use a font size that makes lowercase
letters half the specified font size
@supports (font-size-adjust: 1;) {
article {
font-size-adjust: 0.5;
}
}
// optimal line height
p {