Skip to content

Instantly share code, notes, and snippets.

View andresgutgon's full-sized avatar
:octocat:
Coding things...

Andrés andresgutgon

:octocat:
Coding things...
  • Barcelona
View GitHub Profile
import { MeasuringSystem, MeasuringUnit, MeasuringUnitKind } from "db"
const COMMON = { unitless: { count: MeasuringUnit.count } }
type UnitGroup = Record<MeasuringUnitKind, Record<string, MeasuringUnit>>
type SystemUnits = Record<MeasuringSystem, UnitGroup>
export const units: SystemUnits = {
[MeasuringSystem.METRIC]: {
...COMMON,
@andresgutgon
andresgutgon / AdminCheck.tsx
Created August 2, 2021 08:02
Blitz.js Admin is ROLE 'SUPERADMIN'
import { Suspense, ReactNode } from 'react'
import { Routes, RedirectError, useSession } from "blitz"
import cn from "classnames"
import Layout from "app/core/layouts/Layout"
import type { LayoutProps } from "app/core/layouts/Layout"
const SUPERADMIN_ROLE = 'SUPERADMIN' as never
type CheckIsAdminProps = { children: ReactNode }
version: "3.3"
services:
traefik:
image: traefik:$TRAEFIK_VERSION
command:
- --log.level=DEBUG # DEBUG, INFO, WARN
- --global.sendAnonymousUsage=false
- --api.insecure
# SWAP The fcsonline way
# First make yourself sudo like this
sudo su
# The copy these lines in the console
fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
### Keybase proof
I hereby claim:
* I am andresgutgon on github.
* I am andresgutgon (https://keybase.io/andresgutgon) on keybase.
* I have a public key ASCacdfdFvZwrBEN1muWuTNiEETe2c4gzbkUikI07TRL2Qo
To claim this, I am signing this object:
<div style="clear: both;">
<img src="" alt="" style="float: left;margin-right: 10px;"/>
<div></div>
</div>
@andresgutgon
andresgutgon / README.md
Last active December 3, 2016 17:08
Little mocker excercise. Learn what are the different test doubles we can use when we test our code.

Testing: The little mocker

This is an example trying to apply some lessons learned from Uncle Bob's article The little mocker

In this gist first I'll explain what I learned. Then I'll show you what the code does and finally how I tested the code.

What I learned

When we're making unit test we want to focus on the code we want to test not external dependencies that are not under our control. To make life easier and being able to test on isolation our code without side effects from the rest of the world we use test doubles. Test doubles try to simulate behavior that is in our code but belongs to external agents/objects.

<!DOCTYPE html>
<html>
<head></head>
<style>
* {
box-sizing: border-box;
}
body {
font-size: 13px;
}
var _ = require('underscore');
var config = require('./grunt/webpack/config.js');
var plugins = require('./grunt/webpack/plugins.js');
const env = 'development';
var environments = {
production: {
plugins: plugins[env],
devtool: 'source-map',
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
'use strict';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };