Skip to content

Instantly share code, notes, and snippets.

@dirkluijk
dirkluijk / interceptors.spec.ts
Created June 20, 2018 15:09
Testing Angular interceptors with Spectator
import { HttpErrorResponse, HttpRequest, HttpResponse } from '@angular/common/http';
import { Router } from '@angular/router';
import { createService, createSpyObject } from '@netbasal/spectator';
import { of, throwError } from 'rxjs';
import { RedirectInterceptor } from './redirect-interceptor.service';
import anything = jasmine.anything;
describe('RedirectInterceptorService', () => {
const spectator = createService({
service: RedirectInterceptor,
@xeoncross
xeoncross / logger.js
Last active April 21, 2024 00:26
Expressjs Server Monitoring with Winston + Morgan
const { createLogger, format, transports } = require("winston");
// https://github.com/winstonjs/winston#logging
// { error: 0, warn: 1, info: 2, verbose: 3, debug: 4, silly: 5 }
const level = process.env.LOG_LEVEL || "debug";
function formatParams(info) {
const { timestamp, level, message, ...args } = info;
const ts = timestamp.slice(0, 19).replace("T", " ");
@zakkak
zakkak / .git-commit-template
Last active February 9, 2026 09:44 — forked from adeekshith/.git-commit-template.txt
This commit message template that helps you write great commit messages and enforce it across your team.
# [<tag>] (If applied, this commit will...) <subject> (Max 72 char)
# |<---- Preferably using up to 50 chars --->|<------------------->|
# Example:
# [feat] Implement automated commit messages
# (Optional) Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# (Optional) Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
ReactDOM.render((
<Route path="/" render={() => (
<Shell>
<Switch>
<Route path="/" exact component={Dashboard} />
<Route path="/search" component={Search} />
<Route path="/setup" component={Setup} />
<Route path="/code-maintenance" component={CodeMaintenance} />
<Route path="/organization/new" render={(props) => (
<Organization {...props} isNewOrganization={true}/>
@JeroenVdb
JeroenVdb / snippets.cson
Created December 30, 2016 09:18
Thymeleaf attributes autocomplete support in Atom
'.text.html .meta.tag':
'th:classappend':
'prefix': 'th:classappend'
'body': 'th:classappend="${$1}"'
'th:each':
'prefix': 'th:each'
'body': 'th:each="$1 : ${$2}"'
'th:abbr':
'prefix': 'th:abbr'
'body': 'th:abbr="${$1}"'

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@mxstbr
mxstbr / Readme.md
Last active October 20, 2024 20:44
Enable tab completion for JSX with Emmet in Atom

Enable tab completion for JSX with Emmet in Atom

This guide assumes you have the emmet and language-babel packages already installed in Atom

Gif of the tab completion working

  1. Open the keymap.cson file by clicking on Atom -> Keymap… in the menu bar
  2. Add these lines of code to your keymap:
'atom-text-editor[data-grammar~="jsx"]:not([mini])':
<!doctype>
<html>
<head>
</head>
<body>
<?php
require_once "Classes/PHPExcel.php";
$tmpfname = "test.xlsx";
@mayank-io
mayank-io / pg_truncate_tables.sql
Created January 9, 2016 07:59
Postgres: Truncate all tables in PUBLIC schema for a given USER
-- Running this snippet creates a function. This function can then be executed
-- in this manner:
-- SELECT truncate_tables('postgres');
CREATE OR REPLACE FUNCTION truncate_tables(_username text)
RETURNS void AS
$func$
BEGIN
RAISE NOTICE '%',
-- EXECUTE -- dangerous, test before you execute!

Folder Structure

Please note

While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.

Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.