Skip to content

Instantly share code, notes, and snippets.

View jpenaroche's full-sized avatar

José Angel Peñarroche Delgado jpenaroche

View GitHub Profile
@jpenaroche
jpenaroche / setupJest.js
Created December 5, 2022 14:38 — forked from r3dm1ke/setupJest.js
toBeISODate Jest matcher
expect.extend({
toBeISODate(received) {
// This regexp checks for formatting
if (
!/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/.test(received)
) {
return {
pass: false,
message: `Expected ${received} to be a valid ISO date string`,
};
@jpenaroche
jpenaroche / split.js
Created May 9, 2021 03:00 — forked from NotWoods/split.js
Node.js - Break up a stream and reassemble it so that each line is a chunk.
const stream = require("stream");
/** Simplified version of split() on npm. */
const split = new stream.Transform({
/**
* @param {Buffer | string} chunk is the data from the Readable Stream.
* @param {string} encoding is the file encoding, but isn't used here.
* @param {() => void} next is a callback function called when you finish working
* with this chunk.
*/
@jpenaroche
jpenaroche / mongodb_cheat_sheet.md
Created September 23, 2020 16:03 — forked from bradtraversy/mongodb_cheat_sheet.md
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin: "*"
Header always set Access-Control-Allow-Methods: "POST, OPTIONS"
Header always set Access-Control-Allow-Headers: "Accept, Content-Type, Content-Length, X-Requested-With"
</IfModule>
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
@jpenaroche
jpenaroche / gist:9255cb417d896cf5a156141236ab0bcc
Created April 23, 2020 02:38
MySQL - How to temporarily disable a foreign key constraint?
To disable foreign key constraints when you want to truncate a table:
Use FOREIGN_KEY_CHECKS
SET FOREIGN_KEY_CHECKS=0;
and remember to enable it when you’re done:
SET FOREIGN_KEY_CHECKS=1;
Or you can use DISABLE KEYS:
{"version":1,"resource":"file:///Users/jose/Code/DJ/wsj_article.app/lib/article.app/lib/module/shared/universalAd.js","entries":[{"id":"XxVa.js","timestamp":1649791838204},{"id":"Kjr1.js","timestamp":1649792201355},{"id":"9aEI.js","timestamp":1649792219444},{"id":"eay2.js","timestamp":1649792606482},{"id":"lRQ9.js","timestamp":1649939832132},{"id":"CkFV.js","timestamp":1649942144865},{"id":"JLXx.js","timestamp":1649942261205},{"id":"Uisx.js","timestamp":1649943427385},{"id":"rtN0.js","timestamp":1649943483970},{"id":"C2jP.js","timestamp":1649943584188},{"id":"Qgsl.js","timestamp":1650903156594},{"id":"E4oh.js","timestamp":1650903278221},{"id":"EG8H.js","timestamp":1650903507650}]}
// URL: http://xxx.test/calendar?filter[id]=1&anotherparam=2
$cc = app()->make('App\Http\Controllers\CalendarController');
app()->call([$cc, 'getCalendarV2'], ['filter[id]'=>1, 'anotherparam' => '2']);
{
"status": "success",
"result": [
{
"id": 7,
"name": "penna",
"email": "[email protected]",
"email_verified_at": null,
"locale": "es",
"is_admin": 1,
@jpenaroche
jpenaroche / Media.js
Last active April 2, 2019 15:15
Vue-ORM MTM Polymorphic Relation
import {Model} from '@vuex-orm/core'
// model declaration
export class Media extends Model {
static entity = 'medias'
static fields() {
return {
id: this.attr(null),
disk: this.string(''),
@jpenaroche
jpenaroche / index.html
Created March 13, 2019 18:36
Vuetify Example Pen
<div id="app">
<v-app id="inspire">
<v-data-table
v-bind:headers="headers"
:items="items"
hide-actions
class="elevation-1"
ref="sortableTable"
>
<template slot="items" slot-scope="props">