This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type HttpInterceptor = ( | |
options: FetchOptions, | |
) => Promise<FetchOptions> | FetchOptions; | |
type HttpInstance = { | |
baseURL: string; | |
headers: Record<string, string>; | |
}; | |
export const HTTP_INSTANCE: HttpInstance = { | |
baseURL: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue/dist/vue.js'; | |
Vue.component('search', { | |
template: `<p>{{msg}}</p>`, | |
data() { | |
return { | |
msg: 'bonjour' | |
}; | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, []) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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("\\."); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let mongoose = require('mongoose') | |
let userSchema = new mongoose.Schema({ | |
lastname: { | |
type: String, | |
required: true | |
}, | |
firstname: { | |
type: String, | |
required: true |
NewerOlder