Skip to content

Instantly share code, notes, and snippets.

View gidhon's full-sized avatar
💭
🌌

Gideon Kreitzer gidhon

💭
🌌
View GitHub Profile
@gidhon
gidhon / palindrome.js
Created December 3, 2021 02:29
palindrome checker
/*
* @param String
* Using built-in methods, return true if a given string is a palindrome.
**/
function palindrome(str) {
const invalid = /[\W]/g;
const normalized = str.toLowerCase().replace(invalid, '');
const reversed = normalized.split('').reverse().join('');
return normalized === reversed;
@gidhon
gidhon / settings.json
Created March 28, 2021 19:41
Windows Terminal - Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{07b52e3e-de2c-5db4-bd2d-ba144ed6c273}",
"copyOnSelect": true,
"copyFormatting": false,
"profiles":
{
"defaults":
{
@gidhon
gidhon / express-server-side-rendering.md
Created September 10, 2019 13:23 — forked from joepie91/express-server-side-rendering.md
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti

Keybase proof

I hereby claim:

  • I am gidhon on github.
  • I am gidhon (https://keybase.io/gidhon) on keybase.
  • I have a public key ASCh5-nkgYd67C60GxOj7V8HziFlnQ6dKNO7oihYgqdXTQo

To claim this, I am signing this object:

@gidhon
gidhon / snippets.cson
Created October 20, 2018 16:32
Stylus snippets for Platframe | editor: Atom
'.source.stylus':
'Set size: 2D (equilateral | [width, height])':
prefix: 'size'
body: 'size($1px)'
'Unit conversion: px ⟶ rem':
prefix: 'rem'
body: 'rem($0px)'
'@media: min-width':
prefix: 'Platframe: min-width'
body: '+min($1)'
@gidhon
gidhon / stylus.json
Created October 20, 2018 16:28
Stylus snippets for Platframe | editor: VS Code
{
"Set size: 2D (equilateral | [width, height])":{
"prefix":[
"Platframe | size (both [w, h])",
"size"
],
"body":[
"size($0px)"
],
"description":"Set the width and height of an element"
@gidhon
gidhon / git_commit_reset.md
Last active December 5, 2023 11:17
Creating a new branch to discard commit history

Discard commits while saving changes

Scenario

You have made some commits, pushed it upstream to the remote branch, then realized that some or all of those commits must for some reason not be included. In example, accidently commiting large multimedia files (blobs) that will forever bloat the commit history of the branch.

  1. ensure all changes are commited in your current, "faulty" branch
  2. switch to your master branch
    • git checkout master
  3. update master with latest changes on remote
@gidhon
gidhon / Stylus-Mixin-for-Linear-Gradients.markdown
Last active July 23, 2018 10:49
A Pen by Gideon Kreitzer.

Stylus Mixin for Linear Gradients

A Stylus mixin for linear gradients with support for comma-separated splat arguments. In part created as a work-around / abstraction for this.

The method for retrieving the fall-back background colour can do with some improvement, such as averaging the colours or selecting a colour by means of passing an additional argument.

View it on CodePen