Skip to content

Instantly share code, notes, and snippets.

View psenger's full-sized avatar
:octocat:
Makin Bacon

Philip A Senger psenger

:octocat:
Makin Bacon
View GitHub Profile
@psenger
psenger / README.md
Created August 8, 2023 01:26
[Postgres tips and tricks] #Postgres

Tips and Tricks

how to find where the Configuration file is located

psql -U postgres -c 'SHOW config_file'

@psenger
psenger / frontmatter.js
Created August 3, 2023 01:57 — forked from sudkumar/frontmatter.js
MDX Remark plugin to handle frontmatter
// helps us in parsing the frontmatter from text content
const matter = require('gray-matter')
// helps us safely stringigy the frontmatter as a json object
const stringifyObject = require('stringify-object')
// helps us in getting the reading time for a given text
const readingTime = require('reading-time')
// please make sure you have installed these dependencies
// before proceeding further, or remove the require statements
// that you don't use
@psenger
psenger / readme.md
Created July 31, 2023 03:51
[pass - a unix style password manager] #MacOS

pass

stores to a local db called ~/.password-store

@psenger
psenger / passwordPolicyCheck.js
Created July 29, 2023 12:32
[Password Policy Check Functions contains min, min length, special characters, numbers, upper and lower case] #JavaScript #Functional
const minLength = (min) => (str) => (str||'').toString().trim().length >= min
const contains = (chars, min) => (str) => [...((str||'').toString().trim())].filter(char => (new Set(chars)).has(char)).length >= min
const hasLowerCase = contains('abcdefghijklmnopqrstuvwxyz', 1)
const hasUpperCase = contains('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 1)
const hasNumber = contains('0123456789', 1)
const hasSpecialChar = contains('!@#$%^&*()-+_', 1)
const compose = (...fns) => (x) => fns.map((fn) => fn(x))
const passwordPolicyCheck = compose(
minLength(12),
hasLowerCase,
@psenger
psenger / README.md
Last active August 9, 2023 22:41
[Regular Expression to find all the CSS URL functions without quoted URLS] #RegEx #CSS

Regular Expression to find all the CSS URL functions without quoted URLS

to find all url css commands that do not have quoted URLs

url\(([^"'\)]+)\)
  • match case senstivie url(
  • start capture group 1
@psenger
psenger / README.md
Last active July 17, 2023 04:22
[NextJS - when to use Client vs Server Components] #NextJS

NextJS - when to use Client vs Server Components

Client Server
Use React hooks such as useState, useEffect, useReducer Fetch Data
Interactivity within the component, with event listeners (onClick()) Store sensitive information on server (tokens, API keys, etc.)
Use custom hooks that depend on state, effects. Access backend resources directly
Keep large dependencies on the server
@psenger
psenger / README.md
Last active May 6, 2024 10:19
[Python versions with pip and venv] #Python

How to use different versions of Python on my mac

Why is it so hard to do Python on a mac... well its not so bad.

python3 -m venv myenv
source ./myenv/bin/activate
pip install Pipfile
@psenger
psenger / flatmap.js
Last active July 5, 2023 14:06
[An array of data, that has an array of sub data] #JavaScript #Array #flatMap #flat #reduce #reduceRIght
/**
* Problem: an array of data, that has an array of sub data.
* Three ways to do this:
* - map+split, reduce, push+spread, sort ( side effect: order is not retained )
* - map+split, flat
* - flatMap+split
*/
const values = 'a|b|c|d,e|f,g|h|i|j|k|l'
const A = values.split(',').map((v)=>v.split('|')).reduce((acc,v)=>{
@psenger
psenger / README.md
Last active July 3, 2023 03:26
[Apache HTTPD] #apache #unix

Apache Installation

yum install httpd -y

Default install directory /var/www/html

Apache Starting

@psenger
psenger / CURRY.md
Last active December 18, 2023 06:32
[Monad and Curry] #functionalProgramming

Curry

Currying is the process of turning a function that expects multiple parameters into one that, when supplied fewer parameters, returns a new function that awaits the remaining ones. [1]


[1] https://fr.umio.us/favoring-curry/