Skip to content

Instantly share code, notes, and snippets.

View cuibonobo's full-sized avatar

Jen Garcia cuibonobo

View GitHub Profile
@cuibonobo
cuibonobo / python-memory.md
Last active August 29, 2015 13:57
Checking the memory usage of a python application
@cuibonobo
cuibonobo / ssl.md
Created March 21, 2014 12:28
Creating and distributing self-signed certificates
@cuibonobo
cuibonobo / directorysize.sh
Created March 23, 2014 15:49
Getting the size of all files in a directory. The OS returns the value pretty quickly, but for large directory trees it can take a while. For example, it took about 40s to report the size of a 160GB directory.
du -sh /path/to/directory
@cuibonobo
cuibonobo / git-log-pretty.sh
Created March 24, 2014 14:25
Prettier git log messages. Creates an alias in your global git config file for `git lg`. Use `git lg -p` to see changed lines for each commit. Taken from: https://coderwall.com/p/euwpig
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
@cuibonobo
cuibonobo / web-server-stuff.md
Last active August 29, 2015 13:57
Web server stuff
@cuibonobo
cuibonobo / eve-event-hooks.py
Created March 30, 2014 16:49
A good example of using event hooks to modify Eve data. Taken from: https://github.com/nicolaiarocci/eve/issues/270
# settings
settings = {...}
# authentication
from eve.auth import TokenAuth
import requests
from flask import request, g
class TokenAuth(TokenAuth):
def check_auth(self, token, allowed_roles, resource, method):
# check token against user api
@cuibonobo
cuibonobo / mongo-find-replace.py
Created March 31, 2014 22:26
Find and replace an item in a MongoDB database
import pymongo
# Set up your database
conn = pymongo.Connection()
db = conn.eve
coll = db.assets
# Find every record that contains 'http://127' in the 'thumbnail' field
change_list = list(coll.find({"thumbnail":{"$regex":"http://127"}}))
@cuibonobo
cuibonobo / replica-sets.md
Last active August 29, 2015 13:58
Creating a replica set in MongoDB and getting ElasticSearch to work
@cuibonobo
cuibonobo / elastic-search.md
Last active August 29, 2015 13:58
ElasticSearch stuff
  • The term filter is used to filter by exact values
  • The terms is the same as the term filter, but allows you to specify multiple values to match
  • The range filter allows you to find numbers or dates which fall into the specified range. The operators it accepts are:
    • gt greater than
    • gte greater than or equal to
    • lt less than
    • lte less than or equal to
  • The exists and missing filters are used to find documents where the specified field either has one or more values (exists) or doesn’t have any values (missing)
  • The match_all query simply matches all documents. It is the default query which is used if no query has been specified
  • The match query should be the standard query that you reach for whenever you want to query for a full text or exact value in almost any field