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 jinja2 import Environment, PackageLoader | |
| from weasyprint import HTML, CSS | |
| def render_inst(tmpl, region, state, **kwargs): | |
| template = Environment(loader=PackageLoader(local_env, 'templates')).get_template(tmpl) | |
| file_name = 'Instance_Summary-{0}-{1}-{2}.pdf'.format(region, state, datetime.date.today().strftime('%Y-%m-%d')) | |
| HTML(string=template.render(kwargs)).write_pdf(file_name, stylesheets=[CSS(filename="stylesheets/instance_summary.css")]) |
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
| package main | |
| import ( | |
| "code.google.com/p/go-tour/wc" | |
| "strings" | |
| ) | |
| func WordCount(s string) map[string]int { | |
| m := make(map[string]int) | |
| for _, v := range strings.Fields(s) { |
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
| class Image(models.Model): | |
| image = models.ImageField(storage=images, upload_to='images') | |
| thumbnail = models.ImageField(storage=thumbs, upload_to='thumbnails', null=True, | |
| blank=True) | |
| def __str__(self): | |
| return self.title | |
| def _check_pos(self, pos, x, y): |
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 paramiko | |
| import getpass | |
| def main(): | |
| ssh = paramiko.SSHClient() | |
| ssh.set_missing_host_key_policy( | |
| paramiko.AutoAddPolicy()) | |
| hostname = raw_input('hostname: ') | |
| username = raw_input('username: ') |
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
| # Extension of http://www.yilmazhuseyin.com/blog/dev/create-thumbnails-imagefield-django/ | |
| # updated for Python 3 | |
| from django.core.files.storage import FileSystemStorage | |
| from django.core.files.uploadedfile import SimpleUploadedFile | |
| from PIL import Image | |
| import io | |
| import os | |
| from django.conf import settings |
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
| #include "opencv2/opencv.hpp" | |
| #include <stdio.h> | |
| #include <time.h> | |
| using namespace std; | |
| using namespace cv; | |
| int main(int, char**) { | |
| time_t startTime = time(0) | |
| int frames = 0; |
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 mongoengine import Document, StringField | |
| class MyModel(Document): | |
| name = StringField() | |
| meta = {'allow_inheritance': True } | |
| class TestMyModel(MyModel): | |
| pass |