Skip to content

Instantly share code, notes, and snippets.

type HttpInterceptor = (
options: FetchOptions,
) => Promise<FetchOptions> | FetchOptions;
type HttpInstance = {
baseURL: string;
headers: Record<string, string>;
};
export const HTTP_INSTANCE: HttpInstance = {
baseURL: '',
import React, {Fragment} from 'react'
import PropTypes from 'prop-types'
import {range} from 'ramda'
import styled from 'styled-components'
import {FromLeftToCenter} from '../../styled/Text.style'
import {colors} from '../../../styles/colors'
import {fontSize} from '../../../styles/mixins'
const DEFAULT_MAX_PAGINATION = 5
import Vue from 'vue/dist/vue.js';
Vue.component('search', {
template: `<p>{{msg}}</p>`,
data() {
return {
msg: 'bonjour'
};
}
});
function chunk<T>(arr: T[], size: number = 1): T[][] {
return arr.reduce((acc, it, i) => i % size === 0 ? [...acc, arr.slice(i, i + size)] : acc, [])
}
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch) {
var q = 'task_queue';
ch.assertQueue(q, {durable: true});
ch.prefetch(1);
console.log(" [*] Waiting for messages in %s. To exit press CTRL+C", q);
ch.consume(q, function(msg) {
var amqp = require('amqplib/callback_api');
amqp.connect('amqp://localhost', function(err, conn) {
conn.createChannel(function(err, ch) {
var q = 'task_queue';
var msg = "Hello World!";
ch.assertQueue(q, {durable: true});
ch.sendToQueue(q, new Buffer(msg), {persistent: true});
console.log(" [x] Sent '%s'", msg);
We couldn’t find that file to show.
module.exports.requireId = (req, res, next) => {
if(!req.decode || req.decode._id !== req.params.id || req.decode.role !== 'admin'){
return res.json({
success: false,
message: 'Failed to Authentication'
});
}
next();
}
InputFilter[] filters = new InputFilter[1];
filters[0] = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (end > start) {
String destTxt = dest.toString();
String resultingTxt = destTxt.substring(0, dstart) + source.subSequence(start, end) + destTxt.substring(dend);
if (!resultingTxt.matches("^\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3}(\\.(\\d{1,3})?)?)?)?)?)?")) {
return "";
} else {
String[] splits = resultingTxt.split("\\.");
@anymaniax
anymaniax / user.js
Last active November 23, 2016 19:46
let mongoose = require('mongoose')
let userSchema = new mongoose.Schema({
lastname: {
type: String,
required: true
},
firstname: {
type: String,
required: true