Skip to content

Instantly share code, notes, and snippets.

View barisusakli's full-sized avatar
🎯
Focusing

Barış Uşaklı barisusakli

🎯
Focusing
View GitHub Profile
@ramonfritsch
ramonfritsch / expressjs-rewrite.js
Created November 9, 2016 17:06
URL rewrite on ExpressJS 4.0
....
//This is how you'd do on ExpressJS 3.0
app.get('/my/route1/', function (req, res, next) {
req.url = '/other/route2/';
next('route');
});
app.get('/other/route2/', function (req, res, next) {
res.send('I am other route 2');
@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/ } },
@loisaidasam
loisaidasam / gist:2774350
Created May 23, 2012 09:59
One liner for counting unique IP addresses from nginx logs
# One liner for counting unique IP addresses from nginx logs
# Feel free to comment with better ideas - I'm sure it's not the best way of doing this (I'm no awk ninja!)
#
# Sample output:
#
# $ cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'
# 66.65.145.220 49
# 92.63.28.68 126
cat example.com.access.log | awk -F " " '{a[$1]++ } END { for (b in a) { print b, "\t", a[b] } }'