Skip to content

Instantly share code, notes, and snippets.

View freyes's full-sized avatar
🥑

Felipe Reyes freyes

🥑
View GitHub Profile
@sym3tri
sym3tri / MongoDB update all matching.js
Created March 7, 2011 06:15
How to update a single field in a MongoDB collection for all documents matching a specific criteria
// FROM: http://www.mongodb.org/display/DOCS/Updating#Updating-update%28%29
//
// db.collection.update( criteria, objNew, upsert, multi )
// criteria - query which selects the record to update;
// objNew - updated object or $ operators (e.g., $inc) which manipulate the object
// upsert - if this should be an "upsert"; that is, if the record does not exist, insert it
// multi - if all documents matching criteria should be updated
//
// SQL VERSION:
// UPDATE myTable SET dateField = '2011-01-01' WHERE condField = 'condValue'
@derpston
derpston / gist:2069716
Created March 18, 2012 07:42
Unpacking and repacking initramfs images
# Unpack
gzip -cd /boot/initramfs.example | cpio -i
# Repack
find . | cpio --dereference -o -H newc | gzip > /boot/initramfs.example
@phred
phred / pedantically_commented_playbook.yml
Last active November 3, 2023 01:55
Very complete Ansible playbook, showing off all the options
---
####
#### THIS IS OLD AND OUTDATED
#### LIKE, ANSIBLE 1.0 OLD.
####
#### PROBABLY HIT UP https://docs.ansible.com MY DUDES
####
#### IF IT BREAKS I'M JUST SOME GUY WITH
#### A DOG, OK, SORRY
####
@niedbalski
niedbalski / auth.py
Created November 9, 2012 21:08
hmac-encrypt-request
from Crypto.Hash import HMAC
from Crypto.Hash import SHA
import hashlib
import datetime
class Auth:
@classmethod
def sign(cls, method, c_type, body, uri, key=None):
@joeyAghion
joeyAghion / mongodb_collection_sizes.js
Last active May 23, 2024 15:30
List mongodb collections in descending order of size. Helpful for finding largest collections. First number is "size," second is "storageSize."
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
anonymous
anonymous / mongodb.sh
Created January 20, 2015 19:28
Jump into a mongodb session ( juju )
$ juju ssh 0
machine-0# sudo apt-get install mongodb-clients
machine-0# mongo --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
MongoDB shell version: 2.4.9
connecting to: localhost:37017/admin
juju:PRIMARY> db = db.getSiblingDB("juju")
juju
juju:PRIMARY> show collections
constraints
containerRefs
@niedbalski
niedbalski / mongo.sh
Created February 10, 2015 20:20
Connect to Juju Mongodb
$ juju ssh 0
machine-0# sudo apt-get install mongodb-clients
machine-0# mongo --ssl -u admin -p $(grep oldpassword /var/lib/juju/agents/machine-0/agent.conf | awk -e '{print $2}') localhost:37017/admin
MongoDB shell version: 2.4.9
connecting to: localhost:37017/admin
juju:PRIMARY> db = db.getSiblingDB("juju")
juju
@niedbalski
niedbalski / deployerizer.py
Last active March 17, 2017 19:14
Convert a current running juju environment to a juju-deployer bundle.
#!/usr/bin/env python
from __future__ import print_function
import yaml
import subprocess
import argparse
__author__ = "Jorge Niedbalski <jorge.niedbalski@canonical.com>"
# coding=utf8
"""
salesforce.py - Willie Salesforce Module for displaying
support case information
Copyright 2015, Billy Olsen
Licensed under the Eiffel Forum License 2.
"""
from __future__ import unicode_literals
@niedbalski
niedbalski / netns-lxc.sh
Last active June 22, 2021 03:57
netns-lxc
$ source netns-lxc.sh && sudo veth_interface_for_lxc container_name
veth132