Skip to content

Instantly share code, notes, and snippets.

View nicooga's full-sized avatar

Nicolas Oga nicooga

View GitHub Profile
@nicooga
nicooga / propertyInspectionProxy.ts
Created April 9, 2021 18:47
Use a proxy to inspect properties used in a JS object.
const propertyIsNumeric = (property): boolean => {
if (typeof property === "number") return true;
if (typeof property === "string" && property.match(/\d+/)) return true;
return false;
};
const NON_PROXIED_PROPERTIES = new Set([
"typedAttributes",
"attributes",
"_originalAttributes",
@nicooga
nicooga / Request.ts
Last active August 1, 2020 21:22
Hard excercise from book "Programming Typescript", solved with a hack (type assertion). The objective is to prevent users from calling `.send` on a request that is missing `method` or `url` properties..
type Data = {
[key: string]: string | number | Data
}
type Method = 'GET' | 'POST' | 'PUT' | 'DELETE';
class Request {
constructor(
public url?: string,
public data?: Data,
GET /api/customers Devuelve la lista de usuarios
POSt /api/customers con un JSON string { username, surname, address, email, phone }. Creo un usario
DELETE /api/customers/:id destruyo el cliente con ese ID
import React from "react";
import styled, { createGlobalStyle } from "styled-components";
import { BrowserRouter as Router, Switch, Route, Link, useRouteMatch } from "react-router-dom";
// Components
import Home from "./Home.jsx";
import About from "./About.jsx";
import Proyects from "./Proyects.jsx";
import Contact from "./Contact.jsx";
import {CustomPaper} from "./styledComponents";
import java.io.*;
public class IntStorage {
RandomAccessFile file;
public IntStorage(String fileName) throws FileNotFoundException {
this.file = new RandomAccessFile(fileName, "rw");
}
public void pushInt(int number) throws IOException {
public enum PrinterExceptionReason {
NOT_ENOUGH_INK,
NO_PAPER,
PRINTER_NOT_CONNTECTED,
PRINTER_UNOPERATING
}
public class PrinterException extends Exception {
public int page;
http://localhost:3000/javascript/option-maybe-either-future-monads-js
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
asdf qwer uiop asdf qwer uiop asdf qwer uiop asdf qwer uiop
@nicooga
nicooga / README.md
Last active January 3, 2019 16:11
Factory for creating talents for testing in screening wizard based on Eugene Mironov's code

Talent factory meant to speed up manual testing process, based on Eugene Mironov's code.

Just throw files in /lib and use in console.

Factory methods can be chained and used both from class or instances.

TalentFactory.new(vertical: :desginer).create_user.pass_application_submission.claim_english # ...
TalentFactory.create_developer_on_english_step
@nicooga
nicooga / base_factory.rb
Last active September 4, 2018 21:31
Factory for creating talents for testing in screening wizard.
module BaseFactory
extend ActiveSupport::Concern
include ActiveData::Model
included do
delegate :pipe, to: :new
end
class_methods do
def defop(name, &block)
defmodule Flattening do
def flatten([]), do: []
def flatten([head | tail]) when is_list(head), do: flatten(head) ++ flatten(tail)
def flatten([head | tail]), do: [head | flatten(tail)]
end
IO.inspect Flattening.flatten([[1,2,[3]],[4]])
IO.inspect Flattening.flatten([[1,2,[3]],[4], [5]])
IO.inspect Flattening.flatten([[1,2,[3]],[4], [5, [[6]]]])
IO.inspect Flattening.flatten([[1,2,[3]],[4], [5, [[6]]], [7]])