View docker-compose.yml
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
version: '3' | |
services: | |
vaultwarden: | |
image: vaultwarden/server:latest | |
container_name: vaultwarden | |
restart: always | |
environment: | |
- SIGNUPS_ALLOWED=false | |
- INVITATIONS_ALLOWED=false |
View client_chat.js
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 { getChannels, newSocket } from './sockets/refresh.js' | |
recoverState() | |
if (newSocket()) getChannels() |
View _IPLookup.js
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
// This is an implementation in JavaScript of the most simple yet efficient map suggested here https://stackoverflow.com/a/44950027/1951298 | |
// Nothing special, I just like my JavaScript implementation. | |
const ips = ["100.1.108.246", "101.0.80.218", "101.108.122.200"] | |
const bucket = {} | |
function pushToBucket(bucket, ip) { | |
const intIp = ip.split('.').map(Number) | |
var part1, part2, part3, part4 | |
;[part1, part2, part3, part4] = intIp |
View offline_translator.js
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
// I WILL TRY TO CLEAN UP CODE !!! | |
const path = require('path') | |
const __filePath = path.join(__dirname, './wiki.multi.en.vec') | |
const filePath__ = path.join(__dirname, './wiki.multi.ar.vec') | |
const cachePath = path.join(__dirname, './cache.model') | |
if (typeof String.prototype.trim === 'undefined') { | |
String.prototype.trim = function () { |
View one-to-many-cache-mechanism.js
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
// FIRST, it is to mention this doesn't handle race conditions all over the app per requests !!! | |
// ... that's another story ! A user could update a document and at the same time, another user requests that document (from cache) | |
// Check https://blog.theodo.com/2019/09/handle-race-conditions-in-nodejs-using-mutex/ | |
// At first someone could argue it is just simple, whenever a Listing is modified, | |
// just delete it from Listing cache and iterate through all pages and remove pages containing the Listing. | |
// Well! this is TRUE ! and I didn't thought about that (or thought it would be performance degrading) | |
// So what I'm doing, is to keep a list of updated documents (with up = 3) | |
// When a user first visits a Listing, update up 3 -> 1, 2 -> nil |
View Constraints.js
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
// Constraints to ease code complexity. These constraints reflect | |
// which operations to run on some endpoint on some environment | |
const S = require('fluent-json-schema') | |
const { illustrations, fontFamilies } = require('./hallux.js') | |
const config = require('config') | |
const TAG_SIZE = config.get('TAG_SIZE') | |
const login = S.object() | |
.prop('username', S.string().format(S.FORMATS.EMAIL)) | |
.prop('password', S.string().minLength(3).maxLength(40)) |
View Pipeline.js
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
// author: b@cloud14[at]gmail.com | |
// This file is not self contained, I'm using it for my web-app on back-end. | |
// This gist is an illustration of a simple pattern that could help dealing each time on same data (req.body here) with different logics. | |
const geoEncoder = require('../../data/geo/geoJSONEncoder') | |
const { constraints } = require('../constraints/constraints') | |
const { html, reb, rew } = require('../constraints/regex') | |
const sanitizeHtml = require('sanitize-html') | |
const nlp = require('wink-nlp-utils'); | |
const coordinates = geoEncoder.getBorders() |
View magicMiddleware.js
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
const { constraints } = require('./constraints.js') | |
const { obj, ops } = require('./helpers.js') | |
const borders = require('../../data/geo/country').borders | |
const ConnectSequence = require('connect-sequence') | |
const { celebrate, Joi, errors, Segments } = require('celebrate') | |
const formidable = require('formidable') | |
// Chain wrapper for Strings | |
function stringTransformer(s) { | |
var internal = String(s) |
View main.js
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 htmlNode_1 = document.querySelector('#foo') | |
var htmlNode_2 = document.querySelector('#bar') | |
function funcc1(node) { | |
node.value = node.value.toUpperCase() | |
return node | |
} | |
function funcc2(node) { | |
node.value = node.value.repeat(2) | |
return node | |
} |
View projecthoneypot_nodejs_check.js
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 router = express.Router(); | |
var dns = require('dns'); | |
var visitor_type = { | |
0: 'Search Engine Bot', | |
1: 'Suspicious', | |
2: 'Harvester', | |
3: 'Suspicious, Harvester', | |
4: 'Comment Spammer', | |
5: 'Suspicious, Comment Spammer', | |
6: 'Harvester, Comment Spammer', |
NewerOlder