Skip to content

Instantly share code, notes, and snippets.

View dungvtdev's full-sized avatar

dungvt.dev dungvtdev

View GitHub Profile
@dungvtdev
dungvtdev / octavia.md
Created June 15, 2018 18:12
openstack

install

  • apt install qemu-utils kpartx qemu
  • pip install diskimage-builder

env

  • export DIB_REPOREF_amphora_agent=stable/pike
  • export DIB_REPOLOCATION_amphora_agent=/lab/build_img/octavia_win/

example

  • apt install libguestfs-tools

FIND

Find all

db.collection.find()

Find with condition

db.collection.find({ "date": { $gte:ISODate("2017-07-15T00:00:00Z"), $lt:ISODate("2017-07-16T00:00:00Z") }, "website_id": ObjectId("596f4ea91d41c8acb2d8efdf") })

Find and get specific fields

db.collection.find({}, {"website_id":1})

import json
import uuid
from wsgiref import simple_server
import falcon
import random
import os
myhost = os.uname()[1]
<div ng-app="app" ng-controller="Main as main" class="container">
<h1>Simple Angular Auth - Thinkster</h1>
<input type="text" class="form-control" ng-model="main.username" placeholder="username"><br>
<input type="password" class="form-control" ng-model="main.password" placeholder="password"><br>
<br>
<button class="btn" ng-click="main.register()">Register</button>
<button class="btn" ng-click="main.login()">Login</button>
<button class="btn" ng-click="main.logout()" ng-show="main.isAuthed()">Logout</button>
# Source https://github.com/rduplain/flask-svg-example/blob/master/app.py
import os
from flask import Flask, make_response, render_template, request
app = Flask(__name__)
@dungvtdev
dungvtdev / weblibs.md
Created May 29, 2017 08:33
web app libs
def add_servers(self, servers):
if not servers:
return
self._add_servers_config(servers)
self._restart_service()
def _add_servers_config(self, servers):
cfg_parser = Parser(cf_path)
configuration = cfg_parser.build_configuration()
import json
import uuid
from wsgiref import simple_server
import falcon
import random
class StorageEngine(object):
import os
myhost = os.uname()[1]
def app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
#return [b'Hello, world!']
return myhost
if __name__ == '__main__':
@dungvtdev
dungvtdev / pep20_by_example.py
Created April 8, 2017 16:58 — forked from evandrix/pep20_by_example.py
PEP 20 (The Zen of Python) by example
#!/usr/bin/env python
"""
=====================================
PEP 20 (The Zen of Python) by example
=====================================
Usage: %prog
:Author: Hunter Blanks, hblanks@artifex.org / hblanks@monetate.com