Skip to content

Instantly share code, notes, and snippets.

View Nifled's full-sized avatar
👀

Erick Delfin Nifled

👀
View GitHub Profile
@Nifled
Nifled / .hyper.js
Created August 23, 2018 08:33
dot files
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: 'stable',
@Nifled
Nifled / commit-msg
Last active April 7, 2022 05:35
Script to automatically add JIRA ticket reference as a prefix to commit messages. File must be within project's `/.git/hooks/`
#!/bin/sh
#
# Commit hook to add a JIRA ticket reference as a prefix to any commit messages.
# NOTE: JIRA ticket number MUST be included in branch name or it does nothing...
# Doesn't make any specific checks, just does it.
BRANCH_NAME=$(git branch | grep '*' | sed 's/* //')
REGEX_TICKET_ID='(SOFT-[0-9]{4})' # SOFT can be replaced by any JIRA team name
# Do the regex search
@Nifled
Nifled / tracker.js
Created March 30, 2023 20:11
Coding challenge from BEON
class Tracker {
_servers = [];
/**
*
* @param {string} hostType
* @example
* allocate("south")
*/
allocate(hostType) {
@Nifled
Nifled / errors.ts
Last active June 1, 2023 19:23
Format array of `ValidationError` similar to `class-validator`'s default format. This is handy when creating calling `validate` (which returns `ValidationError[]`
import { validate } from 'class-validator';
const validationErrors = await validate(objInstance);
if (validationErrors.length > 0) {
throw new BadRequestException(
validationErrors.map(
({ property, constraints }) =>
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
`${property}: ${Object.values(constraints!)[0]}`,
@Nifled
Nifled / BaseModel.ts
Last active July 5, 2023 00:09
Serializing objects with unusual properties (Set, Date, any custom class, etc) to proper JSON-compatible objects.
// ...... other BaseModel code
/**
* Recursively serialize properties through class getters
* Returns ready object for JSON.stringify()
*/
public toJSON(): any {
const proto = Object.getPrototypeOf(this);
const jsonObj = {
[BaseModel.umt]: proto.constructor.universalModelType()
-----------------
TMUX CHEATSHEET
-----------------
Prefix for commands and help:
Ctrl-b and sth: issue a command to tmux, inside tmux.
Ctrl-b and ?: see all commands.
-------------------------------------------------------------------
Session commands: