Skip to content

Instantly share code, notes, and snippets.

View k1r0s's full-sized avatar

Ciro Iván k1r0s

View GitHub Profile
@k1r0s
k1r0s / javascript.nanorc
Last active February 27, 2021 21:36
nano editor syntax highlight
## https://nano-editor.org/dist/v2.2/nano.html#Nanorc-Files
syntax "javascript" "\.(js|jsx)$"
## Default
color white "^.+$"
## Decimal, cotal and hexadecimal numbers
color brightblue "\<[-+]?([1-9][0-9]*|0[0-7]*|0x[0-9a-fA-F]+)([uU][lL]?|[lL][uU]?)?\>"
@k1r0s
k1r0s / superfine-stateful-draft.jsx
Last active December 1, 2018 01:04
render functional components with self state
import { h, patch } from "superfine";
const stateful = (comp) => (props) => h("state", {
oncreate: (element) => {
const statefine = element.$$statefine = {};
statefine.state = {};
statefine.currentProps = props;
statefine.selfRender = app(comp, element);
statefine.setState = ss => setTimeout(() => statefine.selfRender(statefine.currentProps, statefine.state = ss({ ...statefine.state }), statefine.setState));
statefine.selfRender(props, { ...statefine.state }, statefine.setState);
@k1r0s
k1r0s / superfine-ee.jsx
Created November 27, 2018 23:30
thoughts on superfine
import { h, patch } from "superfine";
import EvtEmitter from "event-emitter";
const emitter = new EvtEmitter;
let readonlyState = {
count: 0,
text: ""
};
import { AbstractResource } from "@ritley/core";
import UserModel from "../models/user.model";
import ParseReqBody from "../decorators/req-body-json.decorator";
import ValidateSession from "../decorators/validate-session.decorator";
import {
ReqTransformQuery,
Dependency,
Default,
Catch,
import { AbstractResource } from "@ritley/core";
import UserModel from "../models/user.model";
import ParseReqBody from "../decorators/req-body-json.decorator";
import ValidateSession from "../decorators/validate-session.decorator";
import {
Dependency,
Default,
Catch,
InternalServerError,
import { beforeMethod } from "kaop-ts";
import {
BadRequest,
ReqTransformBodyAsync
} from "@ritley/decorators";
function parseRequestBody(meta) {
const [req, res] = meta.args;
req.body.then(body => {
import { AbstractResource } from "@ritley/core";
import DataService from "../services/database.service";
import UserModel from "../models/user.model";
import SessionModel from "../models/session.model";
import {
Dependency,
ReqTransformBodyAsync,
Default,
Catch,
import { AbstractResource } from "@ritley/core";
import SessionModel from "../models/session.model";
import {
Default,
Catch,
MethodNotAllowed,
InternalServerError,
Created,
Unauthorized,
const { setAdapter, AbstractResource } = require("@ritley/core");
const Adapter = require("@ritley/standalone-adapter");
setAdapter(Adapter, {
"port": 8080
});
class DefaultResource extends AbstractResource {
get(req, res) {
import { AbstractResource } from "@ritley/core";
import DataService from "../services/database.service";
import UserModel from "../models/user.model";
import {
Dependency,
ReqTransformBodyAsync,
Default,
Catch,
InternalServerError,