> Devices need sandboxes for agents. AI is coming into the real world. Humble devices gain superpowers when they host user code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- enable dblink support | |
| CREATE EXTENSION dblink; | |
| -- create the connection | |
| SELECT dblink_connect('myconn', 'dbname=tracking-service'); | |
| -- then use the connection | |
| SELECT "oauthId" | |
| FROM "56_profile" local | |
| INNER JOIN dblink('myconn','SELECT DISTINCT user_id FROM "event"') |
Here you may see about bi-directional replication we have used http://2ndquadrant.com/en/resources/bdr/
We use here 64bit ubuntu 14.04 with docker to demonstrate our replication solution. First we need to install docker .
sudo su apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ''' | |
| This is an example of how to send data to Slack webhooks in Python with the | |
| requests module. | |
| Detailed documentation of Slack Incoming Webhooks: | |
| https://api.slack.com/incoming-webhooks | |
| ''' | |
| import json | |
| import requests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '''This script goes along the blog post | |
| "Building powerful image classification models using very little data" | |
| from blog.keras.io. | |
| It uses data that can be downloaded at: | |
| https://www.kaggle.com/c/dogs-vs-cats/data | |
| In our setup, we: | |
| - created a data/ folder | |
| - created train/ and validation/ subfolders inside data/ | |
| - created cats/ and dogs/ subfolders inside train/ and validation/ | |
| - put the cat pictures index 0-999 in data/train/cats |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| import os | |
| import time | |
| import traceback | |
| # pip install slackclient | |
| from slackclient import SlackClient |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # Install fake factory at first. Helps us create 50k customers in odoo | |
| # pip install fake-factory | |
| # Documentation for odoo is listed here | |
| # https://www.odoo.com/documentation/9.0/api_integration.html#calling-methods | |
| # MIT License | |
| # Copyright (c) 2016 Jasim Muhammed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # IMPORTS | |
| # replace osv, orm | |
| find . -type f -name '*.py' | xargs sed -i 's/from openerp.osv import orm$/from odoo import models/g' | |
| find . -type f -name '*.py' | xargs sed -i 's/from openerp.models.orm import Model$/from odoo.models import Model/g' | |
| find . -type f -name '*.py' | xargs sed -i 's/osv.osv_memory/models.TransientModel/g' | |
| find . -type f -name '*.py' | xargs sed -i 's/osv.osv/models.Model/g' | |
| find . -type f -name '*.py' | xargs sed -i 's/osv.except_osv/UserError/g' | |
| find . -type f -name '*.py' | xargs sed -i 's/osv\./models./g' | |
| find . -type f -name '*.py' | xargs sed -i 's/\<orm\./models./g' | |
| find . -type f -name '*.py' | xargs sed -i 's/\(import .*\), osv/\1, models/g' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.db import transaction | |
| @transaction.atomic | |
| def create_user_view(request): | |
| if request.method == 'POST': | |
| user_form = UserCreationForm(request.POST) | |
| profile_form = ProfileForm(request.POST) | |
| if user_form.is_valid() and profile_form.is_valid(): | |
| user = user_form.save() | |
| user.refresh_from_db() # This will load the Profile created by the Signal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Setup an appropriate nginx log_format in the `http` section of your nginx config: | |
| log_format main '$remote_addr $time_iso8601 "$request" ' | |
| '$status $body_bytes_sent "$http_referer" ' | |
| '"$http_host" ' | |
| '"$http_user_agent" "$http_x_forwarded_for" ' | |
| '$request_time '; | |
| # Then save the following as a munin plugin to monitor the last 5 minutes of your nginx access.log file |