Skip to content

Instantly share code, notes, and snippets.

View barisusakli's full-sized avatar
🎯
Focusing

Barış Uşaklı barisusakli

🎯
Focusing
View GitHub Profile
var matches = postData.content.match(/!\[.*?]\(.*?\)/g);
console.log('matches', matches);
if (matches && matches.length) {
matches.forEach(function(image) {
if (image.indexOf('](http://') === -1 && image.indexOf('](https://') === -1 && image.indexOf('](/') === -1) {
console.log('not ALOUD', image);
postData.content = postData.content.replace(image, '');
}
var nconf = require('nconf');
var async = require('async');
nconf.file({
file: 'config.json'
});
var redis = require('redis');
var db = require('./src/database');
@barisusakli
barisusakli / logins.js
Created January 6, 2015 19:38
get user logins between dates
var nconf = require('nconf');
var async = require('async');
var fs = require('fs');
nconf.file({
file: 'config.json'
});
@barisusakli
barisusakli / mainpost.js
Last active August 29, 2015 14:14
add main post content to all topic lists
//use filter:topics.get in plugin.json
//{ "hook": "filter:topics.get", "method": "addMainPostContent"}
module.addMainPostContent = function(data, callback) {
var topics = data.topics;
var keys = topics.map(function(topic) {
return topic && 'topic:' + topic.tid;
});
@barisusakli
barisusakli / user_content.js
Created March 16, 2015 17:14
Get posts and topics of user
'use strict';
/*globals require, console, process */
var nconf = require('nconf');
var async = require('async');
var fs = require('fs');
nconf.file({
file: 'config.json'
@barisusakli
barisusakli / doc_size.js
Last active July 11, 2023 14:53
Get biggest document in mongo
#mongodb queries
db.objects.find({ $and: [
{ _id: { $gt: ObjectId("5b06052649f0a0999558b960")} },
{ _key: { $not: /^anal.*/ } },
{ _key: { $not: /^group.*/ } },
{ _key: { $not: /^user/ } },
{ _key: { $not: /^post/ } },
{ _key: { $not: /^topic/ } },
{ _key: { $not: /^chat/ } },
@barisusakli
barisusakli / create_users.js
Last active August 29, 2015 14:25
Create lots of users in nodebb
'use strict';
/*globals require, console, process */
var nconf = require('nconf');
var async = require('async');
nconf.file({
@barisusakli
barisusakli / ratelimit-req.js
Created August 28, 2015 01:17
rate limit requests
ratelimit.rateLimitReq = function(req, res, next) {
if (!req.session) {
return next();
}
req.session.lastRequestTime = req.session.lastRequestTime || 0;
var now = Date.now();
if (now - req.session.lastRequestTime < 200) {
if (res.locals.isAPI) {
res.status(429).json('too-many-requests');
@barisusakli
barisusakli / post_count.js
Last active July 26, 2016 10:28
fix post counts in topic hash if they are out of sync
'use strict';
/*globals require, console, process */
var nconf = require('nconf');
var async = require('async');
nconf.file({
file: 'config.json'
});
@barisusakli
barisusakli / hack.cpp
Created August 11, 2016 23:18
Hidden and Dangerous save game hack
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
void doTheHack()
{
FILE *pFile;
FILE *pOut;
char *buffer;
long fileSize;