Skip to content

Instantly share code, notes, and snippets.

View javierfdezg's full-sized avatar

Javier Fernández javierfdezg

  • Why Not Soluciones, S.L.
  • Madrid, Spain
View GitHub Profile
@javierfdezg
javierfdezg / mongo-backup-to-s3.sh
Created June 1, 2016 07:25
MongoDB Backup and upload to S3
#!/bin/bash
cd /tmp
rm -rf backup
mkdir backup
cd backup
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
MONGODUMP_PATH="/usr/bin/mongodump"
@javierfdezg
javierfdezg / mongo-add-year.sh
Last active January 14, 2016 10:33
Command to modify the date on all the records of a MongoDB collection
// Command:
// Change database for your db name and collection for your collection name
// Remove limit(1). Is there in order to avoid accidents ;)
mongo database --eval \"db.collection.find().limit(1).forEach(function(doc){ var nd = new Date(doc.created_at); nd.setDate(nd.getDate() + 1); doc.created_at = new ISODate(nd.toISOString()); db.collection.save(doc)});"
/* The function in a more readable fashion :)
function(doc) {
var nd = new Date(doc.created_at);
nd.setDate(nd.getDate() + 1);
@javierfdezg
javierfdezg / style.css
Created September 3, 2015 09:36
Responsive Full Background Image
.body {
background-image: url(http://placehold.it/1600x900);
background-position: center center;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
background-color: #ffffff;
background-size: cover;
}
@javierfdezg
javierfdezg / mongo-install-ubuntu-14.10.sh
Last active December 26, 2017 21:49
Installing mongodb in Ubuntu 14.10
# Setting up the repo
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb.list
# Updating and installing
sudo apt-get update
# WARNING: check out the -y here...
sudo apt-get install -y mongodb-org
# For a specific version, use this command
module.exports = function () {
return {
_state : {
views : 'views'
},
set : function(key, val) { this._state[key] = val; }
};
};
@javierfdezg
javierfdezg / git-diff-create-apply-patch
Last active August 29, 2015 14:17
Creating and applying patches using git diff
# Creating a patch:
cd /path/of/the/root/of/the/project
git diff --no-prefix > /path/to/patch_file
#Applying a patch
cd /path/of/the/root/of/the/project
patch -p0 < /path/to/patch_file
@javierfdezg
javierfdezg / mongodb-regexp-javascript
Created March 25, 2015 17:14
Build Mongodb regexp query dynamically
var query = {};
var search = {
field: 'name',
value: 'Your value'
};
query[search.field] = {
$regex: new Regexp(search.value),
$options: "i"